use Digest::MD5 "md5_hex"; my @user_info = map { $ENV{$_} } grep { /USER|REMOTE/ } keys %ENV; print md5_hex( rand() . join('', @user_info) );