- or download this
open IN, $infile or die "Can't open input file: $!";
- or download this
my %set;
my $substit = "";
...
while $set{$randchar}++;
$substit .= $randchar;
}
- or download this
my @alpha = split //, "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- or download this
my @crypt = @alpha;
fisher_yates_shuffle(\@crypt);
- or download this
my $substit = join '', @crypt;
- or download this
sub fisher_yates_shuffle {
my $array = shift;
...
}
return join '', @$array;
}
- or download this
Benchmark: timing 5000 iterations of orig, f_yates, hash...
orig: 33 secs (23.60 usr 0.00 sys = 23.60 cpu)
f_yates: 5 secs ( 2.88 usr 0.00 sys = 2.88 cpu)
hash: 13 secs ( 5.68 usr 0.00 sys = 5.68 cpu)