#! /usr/bin/perl -w
use strict;
use warnings;
my $length = shift || 32;
my $customchars = shift;
my @chars;
@chars = split(//, $customchars) if defined($customchars);
@chars = ('a'..'z','A'..'Z','0'..'9','_') unless defined($customchars);
my $string;
foreach (1..$length) {
$string .= $chars[rand @chars];
}
print $string."\n";
No comments:
Post a Comment