#! perl -sw
use 5.010;
use strict;
use List::Util qw[ shuffle ];
our $I ||= 1e6;
sub genHash {
my %hash;
@hash{ shuffle 'a'..'d' } = 1 .. 4;
return \%hash;
}
my $datum = join ' ', keys %{ genHash() };
warn $datum . "\n";
for my $i ( 1 .. $I ) {
my $test = join ' ', keys %{ genHash() };
die "test failed after $i iters: $datum vs. $test\n"
unless $datum eq $test;
}
say "Test passed for $I iterations"
__END__
C:\test>junk2
c a b d
Test passed for 1000000 iterations
####
@hashA{ 'a'..'d' } = 1..4;;
@hashB{ 'a'..'j' } = 1 .. 10;;
delete $hashB{ $_ } for 'e' .. 'j';;
print scalar %hashA;;
4/8
print scalar %hashB;;
4/16
print join ' ', keys %hashA;;
c a b d
print join ' ', keys %hashB;;
a d c b
####
my $value_key = join $;, @students{ sort keys %{ $students{ $key } } };