1Data::GUID(3) User Contributed Perl Documentation Data::GUID(3)
2
3
4
6 Data::GUID - globally unique identifiers
7
9 version 0.049
10
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
25 Data::GUID provides a simple interface for generating and using
26 globally unique identifiers.
27
29 new
30 my $guid = Data::GUID->new;
31
32 This method returns a new globally unique identifier.
33
35 These method returns a new Data::GUID object for the given GUID value.
36 In all cases, these methods throw an exception if given invalid input.
37
38 from_string
39 my $guid = Data::GUID->from_string("B0470602-A64B-11DA-8632-93EBF1C0E05A");
40
41 from_hex
42 # note that a hex guid is a guid string without hyphens and with a leading 0x
43 my $guid = Data::GUID->from_hex("0xB0470602A64B11DA863293EBF1C0E05A");
44
45 from_base64
46 my $guid = Data::GUID->from_base64("sEcGAqZLEdqGMpPr8cDgWg==");
47
48 from_data_uuid
49 This method returns a new Data::GUID object if given a Data::UUID
50 value. Because Data::UUID values are not blessed and because
51 Data::UUID provides no validation method, this method will only throw
52 an exception if the given data is of the wrong size.
53
55 string_guid_regex
56 hex_guid_regex
57 base64_guid_regex
58 These methods return regex objects that match regex strings of the
59 appropriate type.
60
61 from_any_string
62 my $string = get_string_from_ether;
63
64 my $guid = Data::GUID->from_any_string($string);
65
66 This method returns a Data::GUID object for the given string, trying
67 all known string interpretations. An exception is thrown if the value
68 is not a valid GUID string.
69
70 best_guess
71 my $value = get_value_from_ether;
72
73 my $guid = Data::GUID->best_guess($value);
74
75 This method returns a Data::GUID object for the given value, trying
76 everything it can. It works like "from_any_string", but will also
77 accept Data::UUID values. (In effect, this means that any sixteen byte
78 value is acceptable.)
79
81 These methods return various string representations of a GUID.
82
83 as_string
84 This method returns a "traditional" GUID/UUID string representation.
85 This is five hexadecimal strings, delimited by hyphens. For example:
86
87 B0470602-A64B-11DA-8632-93EBF1C0E05A
88
89 This method is also used to stringify Data::GUID objects.
90
91 as_hex
92 This method returns a plain hexadecimal representation of the GUID,
93 with a leading "0x". For example:
94
95 0xB0470602A64B11DA863293EBF1C0E05A
96
97 as_base64
98 This method returns a base-64 string representation of the GUID. For
99 example:
100
101 sEcGAqZLEdqGMpPr8cDgWg==
102
104 compare_to_guid
105 This method compares a GUID to another GUID and returns -1, 0, or 1, as
106 do other comparison routines.
107
108 as_binary
109 This method returns the packed binary representation of the GUID. At
110 present this method relies on Data::GUID's underlying use of
111 Data::UUID. It is not guaranteed to continue to work the same way, or
112 at all. Caveat invocator.
113
115 Data::GUID does not export any subroutines by default, but it provides
116 a few routines which will be imported on request. These routines may
117 be called as class methods, or may be imported to be called as
118 subroutines. Calling them by fully qualified name is incorrect.
119
120 use Data::GUID qw(guid);
121
122 my $guid = guid; # OK
123 my $guid = Data::GUID->guid; # OK
124 my $guid = Data::GUID::guid; # NOT OK
125
126 guid
127 This routine returns a new Data::GUID object.
128
129 guid_string
130 This returns the string representation of a new GUID.
131
132 guid_hex
133 This returns the hex representation of a new GUID.
134
135 guid_base64
136 This returns the base64 representation of a new GUID.
137
138 guid_from_anything
139 This returns the result of calling the "from_any_string" method.
140
142 • add namespace support
143
144 • remove dependency on wretched Data::UUID
145
146 • make it work on 5.005
147
149 Ricardo SIGNES <rjbs@cpan.org>
150
152 Ricardo SIGNES <rjbs@codesimply.com>
153
155 This software is copyright (c) 2006 by Ricardo SIGNES.
156
157 This is free software; you can redistribute it and/or modify it under
158 the same terms as the Perl 5 programming language system itself.
159
160
161
162perl v5.32.1 2021-01-27 Data::GUID(3)