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);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Safe for SQL
by valdez (Monsignor) on Dec 10, 2002 at 17:08 UTC | |
Re: Safe for SQL
by John M. Dlugosz (Monsignor) on Dec 10, 2002 at 17:05 UTC | |
Re: Safe for SQL
by hiseldl (Priest) on Dec 10, 2002 at 17:08 UTC | |
by Abigail-II (Bishop) on Dec 10, 2002 at 17:48 UTC | |
by hiseldl (Priest) on Dec 10, 2002 at 20:14 UTC | |
Re: Safe for SQL
by perlplexer (Hermit) on Dec 10, 2002 at 16:49 UTC | |
by Anonymous Monk on Dec 10, 2002 at 16:54 UTC | |
by LD2 (Curate) on Dec 10, 2002 at 17:00 UTC | |
by Anonymous Monk on Dec 10, 2002 at 17:03 UTC | |
by jk2addict (Chaplain) on Dec 17, 2002 at 19:43 UTC | |
Re: Safe for SQL
by Anonymous Monk on Dec 10, 2002 at 18:48 UTC | |
by jk2addict (Chaplain) on Dec 11, 2002 at 21:00 UTC | |
Re: Safe for SQL
by Anonymous Monk on Dec 10, 2002 at 17:15 UTC | |
by merlyn (Sage) on Dec 10, 2002 at 17:59 UTC | |
Re: Safe for SQL
by Rudif (Hermit) on Dec 12, 2002 at 00:45 UTC |
Back to
Seekers of Perl Wisdom