1Data::GUID(3)         User Contributed Perl Documentation        Data::GUID(3)
2
3
4

NAME

6       Data::GUID - globally unique identifiers
7

VERSION

9       version 0.050
10

SYNOPSIS

12         use Data::GUID;
13
14         my $guid = Data::GUID->new;
15
16         my $string = $guid->as_string; # or "$guid"
17
18         my $other_guid = Data::GUID->from_string($string);
19
20         if (($guid <=> $other_guid) == 0) {
21           print "They're the same!\n";
22         }
23

DESCRIPTION

25       Data::GUID provides a simple interface for generating and using
26       globally unique identifiers.
27

PERL VERSION SUPPORT

29       This module has an extremely long-term perl support period.  That means
30       it will not require a version of perl released fewer than ten years
31       ago.
32
33       Although it may work on older versions of perl, no guarantee is made
34       that the minimum required version will not be increased.  The version
35       may be increased for any reason, and there is no promise that patches
36       will be accepted to lower the minimum required perl.
37

GETTING A NEW GUID

39   new
40         my $guid = Data::GUID->new;
41
42       This method returns a new globally unique identifier.
43

GUIDS FROM EXISTING VALUES

45       These method returns a new Data::GUID object for the given GUID value.
46       In all cases, these methods throw an exception if given invalid input.
47
48   from_string
49         my $guid = Data::GUID->from_string("B0470602-A64B-11DA-8632-93EBF1C0E05A");
50
51   from_hex
52         # note that a hex guid is a guid string without hyphens and with a leading 0x
53         my $guid = Data::GUID->from_hex("0xB0470602A64B11DA863293EBF1C0E05A");
54
55   from_base64
56         my $guid = Data::GUID->from_base64("sEcGAqZLEdqGMpPr8cDgWg==");
57
58   from_data_uuid
59       This method returns a new Data::GUID object if given a Data::UUID
60       value.  Because Data::UUID values are not blessed and because
61       Data::UUID provides no validation method, this method will only throw
62       an exception if the given data is of the wrong size.
63

IDENTIFYING GUIDS

65   string_guid_regex
66   hex_guid_regex
67   base64_guid_regex
68       These methods return regex objects that match regex strings of the
69       appropriate type.
70
71   from_any_string
72         my $string = get_string_from_ether;
73
74         my $guid = Data::GUID->from_any_string($string);
75
76       This method returns a Data::GUID object for the given string, trying
77       all known string interpretations.  An exception is thrown if the value
78       is not a valid GUID string.
79
80   best_guess
81         my $value = get_value_from_ether;
82
83         my $guid = Data::GUID->best_guess($value);
84
85       This method returns a Data::GUID object for the given value, trying
86       everything it can.  It works like "from_any_string", but will also
87       accept Data::UUID values.  (In effect, this means that any sixteen byte
88       value is acceptable.)
89

GUIDS INTO STRINGS

91       These methods return various string representations of a GUID.
92
93   as_string
94       This method returns a "traditional" GUID/UUID string representation.
95       This is five hexadecimal strings, delimited by hyphens.  For example:
96
97         B0470602-A64B-11DA-8632-93EBF1C0E05A
98
99       This method is also used to stringify Data::GUID objects.
100
101   as_hex
102       This method returns a plain hexadecimal representation of the GUID,
103       with a leading "0x".  For example:
104
105         0xB0470602A64B11DA863293EBF1C0E05A
106
107   as_base64
108       This method returns a base-64 string representation of the GUID.  For
109       example:
110
111         sEcGAqZLEdqGMpPr8cDgWg==
112

OTHER METHODS

114   compare_to_guid
115       This method compares a GUID to another GUID and returns -1, 0, or 1, as
116       do other comparison routines.
117
118   as_binary
119       This method returns the packed binary representation of the GUID.  At
120       present this method relies on Data::GUID's underlying use of
121       Data::UUID.  It is not guaranteed to continue to work the same way, or
122       at all.  Caveat invocator.
123

IMPORTING

125       Data::GUID does not export any subroutines by default, but it provides
126       a few routines which will be imported on request.  These routines may
127       be called as class methods, or may be imported to be called as
128       subroutines.  Calling them by fully qualified name is incorrect.
129
130         use Data::GUID qw(guid);
131
132         my $guid = guid;             # OK
133         my $guid = Data::GUID->guid; # OK
134         my $guid = Data::GUID::guid; # NOT OK
135
136   guid
137       This routine returns a new Data::GUID object.
138
139   guid_string
140       This returns the string representation of a new GUID.
141
142   guid_hex
143       This returns the hex representation of a new GUID.
144
145   guid_base64
146       This returns the base64 representation of a new GUID.
147
148   guid_from_anything
149       This returns the result of calling the "from_any_string" method.
150

TODO

152       •   add namespace support
153
154       •   remove dependency on wretched Data::UUID
155
156       •   make it work on 5.005
157

AUTHOR

159       Ricardo SIGNES <rjbs@semiotic.systems>
160
162       This software is copyright (c) 2006 by Ricardo SIGNES.
163
164       This is free software; you can redistribute it and/or modify it under
165       the same terms as the Perl 5 programming language system itself.
166
167
168
169perl v5.34.0                      2022-01-21                     Data::GUID(3)
Impressum