From bac31d9c114b8c63ee61d4ca7fd51be66dce979b Mon Sep 17 00:00:00 2001 From: Gerhard Gonter <ggonter@gmail.com> Date: Sat, 11 Apr 2015 05:50:48 +0200 Subject: [PATCH] fallback mechanism for UUID module on cygwin --- perl/Gnome-Tomboy/lib/Tomboy.pm | 53 ++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/perl/Gnome-Tomboy/lib/Tomboy.pm b/perl/Gnome-Tomboy/lib/Tomboy.pm index fe90d3b..128b84e 100644 --- a/perl/Gnome-Tomboy/lib/Tomboy.pm +++ b/perl/Gnome-Tomboy/lib/Tomboy.pm @@ -25,37 +25,42 @@ use strict; use POSIX; -eval { - require UUID; - - sub get_uuid - { - my ($uuid, $uuid_str); - UUID::generate ($uuid); - UUID::unparse ($uuid, $uuid_str); - $uuid_str; - } -}; - -if ($@) +BEGIN { - print "no UUID\n"; - eval { - use Data::UUID; + eval + { + require UUID; - sub get_uuid2 + sub get_uuid { - my $uc= new Data::UUID; - my $str= $uc->create_str(); - $str =~ tr/A-F/a-f/; - $str; + my ($uuid, $uuid_str); + UUID::generate ($uuid); + UUID::unparse ($uuid, $uuid_str); + $uuid_str; } - *get_uuid= *get_uuid2; }; - if ($@) { die "install either UUID or Data::UUID"; } -} + if ($@) + { + eval + { + require Data::UUID; + }; + if ($@) { die "install either UUID or Data::UUID"; } + else + { + sub get_uuid2 + { + my $uc= new Data::UUID; + my $str= $uc->create_str(); + $str =~ tr/A-F/a-f/; + $str; + } + *get_uuid= *get_uuid2; + } + } +} my %options_passed= map { $_ => 1 } qw(--note-path); # used by start_tb() function -- GitLab