Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Would the following code produce an Id equvialnt to M$'s GUID and/or something that would be totally safe to use in a SQL insert?
#!/usr/local/bin/perl use MD5; use Time::HiRes qw /time/; my $UniqueId = substr(MD5->hexhash(time(). {}. rand(). $$. 'SomeText') +, 0, 32); $UniqueId=~tr/[a-z]/[A-Z]/; $UniqueId=~s/^((\d|\w){8})((\d|\w){4})((\d|\w){4})((\d|\w){4})((\d|\w) +*)$/\{$1\-$3\-$5\-$7\-$9\}/; print $UniqueId; exit(0);
Back to
Seekers of Perl Wisdom