Package: libossp-uuid-perl
Version: 1.6.2-1+b1
Severity: normal
Tags: patch
Data::UUID supports passing UUID strings without hyphens to the from_string
function.
This is made use of in the test suite for Data::GUID:
{
my $guid = Data::GUID->new;
my $str = $guid->as_string;
$str =~ s/-//g;
my $copy = Data::GUID->from_string($str);
is($guid->as_string, $copy->as_string, "we can from_string a dash-less str");
}
(Data::GUID uses Data::UUID internally.)
Please find attached a patch to add support for this in libossp-uuid-perl.
Tim
diff --git a/perl/uuid_compat.pm b/perl/uuid_compat.pm
index fdc5712..78546cd 100644
--- a/perl/uuid_compat.pm
+++ b/perl/uuid_compat.pm
@@ -93,7 +93,9 @@ sub from_string {
$uuid->import('str',
$str =~ /^0x/
? join '-', unpack('x2 a8 a4 a4 a4 a12', $str)
- : $str
+ : $str =~ /-/
+ ? $str
+ : join '-', unpack('A8 A4 A4 A4 A12', $str)
);
return $uuid->export('bin');
}
diff --git a/perl/uuid_compat.ts b/perl/uuid_compat.ts
index 12507c6..74372f2 100644
--- a/perl/uuid_compat.ts
+++ b/perl/uuid_compat.ts
@@ -28,7 +28,7 @@
## uuid_compat.ts: Data::UUID Backward Compatibility Perl API (Perl test
suite part)
##
-use Test::More tests => 14;
+use Test::More tests => 16;
BEGIN {
use_ok('Data::UUID');
@@ -53,3 +53,5 @@ ok($uuid7 = NameSpace_URL);
ok($uuid8 = $ug->from_string("6ba7b811-9dad-11d1-80b4-00c04fd430c8"));
ok($ug->compare($uuid7, $uuid8) == 0);
+ok($uuid9 = $ug->from_string("6ba7b8119dad11d180b400c04fd430c8"));
+ok($ug->compare($uuid7, $uuid9) == 0);