UUID::Random - Generate random uuid strings


UUID-Random documentation Contained in the UUID-Random distribution.

Index


Code Index:

NAME

Top

UUID::Random - Generate random uuid strings

SYNOPSIS

Top

  use UUID::Random;
  my $uuid = UUID::Random::generate;

DESCRIPTION

Top

This module generates random uuid strings. It does not satisfy any of the points listed in RFC 4122 (http://tools.ietf.org/html/rfc4122) but the default format.

SEE ALSO

Top

If you need RFC compliant UUID strings have a look at Data::UUID

AUTHOR

Top

Moritz Onken, <onken@houseofdesign.de>

COPYRIGHT AND LICENSE

Top


UUID-Random documentation Contained in the UUID-Random distribution.

package UUID::Random;

require 5.006_001;
use strict;
use warnings;


our $VERSION = '0.04';

sub generate {
  my @chars = ('a'..'f',0..9);
  my @string;
  push(@string, $chars[int(rand(16))]) for(1..32);
  splice(@string,8,0,'-');
  splice(@string,13,0,'-');
  splice(@string,18,0,'-');
  splice(@string,23,0,'-');
  return join('', @string);
}

1;
__END__