in reply to Alpha/Numeric random generating
Restricting to alphanumerics, as your title suggests:
#!/usr/bin/perl use warnings; use strict; use constant PWCHARS => ['0'..'9', 'A'..'Z', 'a'..'z']; sub rand_char { PWCHARS->[rand @PWCHARS] } my $foo; for (1..( ARGV[0] || 8 ) ) { $foo .= rand_char; } print $foo, $/;
This runs from the command line, with the number of characters desired as the first argument. The default is eight characters.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Alpha/Numeric random generating
by waswas-fng (Curate) on Nov 08, 2002 at 21:46 UTC | |
by FamousLongAgo (Friar) on Nov 08, 2002 at 22:38 UTC | |
by no_slogan (Deacon) on Nov 09, 2002 at 02:02 UTC |