Scotmonk has asked for the wisdom of the Perl Monks concerning the following question:
# Perl program to demonstrate the # splitting into the hash #!/usr/bin/perl use strict; use warnings; # variables used for computations my $linecount; my $start = time; my $column_count; my $file_errors = 0; my %distance; my %consec_two; my %consec_three; my %adj_row; my @prev; #----------------------------------------------------- my @items = (2,14,7,17,1,12,3,4,11,5,13,6,8,10,9,16,15,18); print "@items\n\n"; my @wrongsort = sort @items; print "@wrongsort\n\n"; @items = map {sprintf '%02u', $_ } @items; print "@items\n\n"; @items = sort @items; print "@items\n\n\n"; $column_count = @items; my ($odd)=(0); my ($even)=(0); print "Column Count = ","$column_count\n"; map {$_ % 2 ? $odd++ : $even++} @items; print "Odd = ","$odd\n"; print "Even = ","$even\n"; print "\n\n"; my %odd_even; print "\%odd_even hash contents \t\t", %odd_even, "\n\n"; + $odd_even{"$odd $even"}++; print "\%odd_even hash contents \t\t", %odd_even, "\n\n"; print "\%odd_even contents \t\t", $odd_even{0}, "\n\n"; # compute average for each row # first adding them all my %average; my $sum; map {$sum += $_} @items; my $avg = $sum / @items; $avg = ($avg - int($avg)) >= 0.5 ? int($avg) + 1 : int($avg); $average{$avg}++; print "AVERAGE hash contents \t\t", %average, "\n\n"; print "AVERAGE hash contents \t\t", $average{0}, "\n\n";
|
|---|