ibanix has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
I've got the need to generate a psuedo-random 8-character string. This is what I coded up:
Many thanks,
ibanix
$ echo '$0 & $0 &' > foo; chmod a+x foo; foo;
I've got the need to generate a psuedo-random 8-character string. This is what I coded up:
This works, but I suspect it isn't the best way to do it. As you can tell, it only returns uppercase letters ("A" .. "Z"). Is there a better way to go about this?my $string; for (0..7) { $string .= chr( int(rand(25) + 65) ); } print "$string\n";
Many thanks,
ibanix
$ echo '$0 & $0 &' > foo; chmod a+x foo; foo;
Back to
Seekers of Perl Wisdom