I'm new to Perl, and I need to generate a unique ID with 6 characters and only numbers, is there a way to do that simply?
I found :
use UUID::Generator::PurePerl;
sub create_search_id {
my $this =shift;
my $args=shift;
my $ug = UUID::Generator::PurePerl->new();
my $uuid1 = $ug->generate_v1();
return $uuid1;
}
But the use
statement generates an internal server error... Thanks !
A UUID is a special form of unique identifier; any UUID-generating module is unlikely to support creating an identifier in the form you want.
I'm not certain what "6 characters and only numbers" means; if you mean 6 digits, just something like this:
But to make it unique, you'd need to be able to check that it isn't already in use, and you haven't told us anything about how you are using it.