2012-03-01 07:59:31 -08:00
|
|
|
package DDG::Goodie::GUID;
|
|
|
|
|
|
|
|
use DDG::Goodie;
|
|
|
|
use Data::GUID;
|
|
|
|
|
|
|
|
triggers start => 'globally', 'universally', 'rfc', 'guid', 'uuid';
|
2012-05-23 19:05:08 -07:00
|
|
|
|
2012-03-20 21:08:12 -07:00
|
|
|
zci answer_type => "guid";
|
2012-05-23 19:05:08 -07:00
|
|
|
|
2012-11-06 14:39:44 -08:00
|
|
|
primary_example_queries 'guid';
|
|
|
|
secondary_example_queries 'uuid';
|
|
|
|
description 'generate a unique indentifier';
|
|
|
|
name 'GUID';
|
|
|
|
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/GUID.pm';
|
|
|
|
category 'computing_tools';
|
|
|
|
topics 'programming';
|
|
|
|
attribution twitter => 'crazedpsyc',
|
|
|
|
cpan => 'CRZEDPSYC' ;
|
|
|
|
|
2012-03-01 07:59:31 -08:00
|
|
|
my %guid = (
|
|
|
|
'guid' => 0,
|
|
|
|
'uuid' => 1,
|
|
|
|
'globally unique identifier' => 0,
|
|
|
|
'universally unique identifier' => 1,
|
|
|
|
'rfc 4122' => 0,
|
|
|
|
);
|
|
|
|
|
|
|
|
handle query_lc => sub {
|
|
|
|
return unless exists $guid{$_};
|
|
|
|
if (my $guid = Data::GUID->new) {
|
|
|
|
if ($guid{$_}) {
|
|
|
|
$guid = lc $guid;
|
|
|
|
} else {
|
|
|
|
$guid = qq({$guid});
|
|
|
|
}
|
2012-03-18 13:17:36 -07:00
|
|
|
$guid .= ' (randomly generated)';
|
2012-03-01 07:59:31 -08:00
|
|
|
return $guid;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
1;
|