Perl equiv to PHP’s md5(uniqid(rand(), true)

Trying to shoehorn some data from the back into the wp_connections database, I needed a perl equiv to the md5(uniqid(rand(), true) function. From some general suggestions at http://www.experts-exchange.com/Programming/Languages/Scripting/Perl/Q_26773756.html came up with the following snippet:

use Digest::MD5 qw (md5_hex);
use Data::Uniqid qw (suniqid uniqid luniqid );

sub gen_token {
# approx equiv to md5(uniqid(rand(), true));
return md5_hex(uniqid);
}

Will also need to use Scott Hurring’s http://hurring.com/scott/code/perl/serialize/ to get it fully into the needed format…

Leave a Reply