[Purdue-pm] an example Perl 6 program
Mark Senn
mark at purdue.edu
Thu Aug 2 19:31:36 PDT 2018
Below is an example Perl 6 program.
Thought you might be interested. -mark
#!/home/pier/e/mark/sw/rakudo-star-2018.04/bin/perl6
# Print an error message if we're using Perl 5.
use v6;
sub MAIN(Bool :$h)
{
# Was "-h" option given on command line?
($h) and do {
# Print "Usage: password" on standard error.
$*ERR.say('Usage: password');
exit 1;
}
# Set @char array to 0...9, A...Z, a...z.
my @char = ('0'...'9', 'A'...'Z', 'a'...'z');
# Set @password array to 9 through 16 random elements of @char.
my @password = @char.pick xx (9...16).pick;
# Print the 9 to 16 character password.
say join '', @password;
}
More information about the Purdue-pm
mailing list