my $recordfile = "/foo/bar/copy.txt"; my %record; open (FILE, "$recordfile") or die "Can't open $recordfile: $!\n"; while(<FILE>) { if (/^(..)/) { $record{$1}++; } } print "The Total number or records = $.\n\n"; for (sort keys %record) { print "$_ reports $record{$_} records.\n"; } ## Or, to output the records from fewest to most: for (sort {$record{$a} <=> $record{$b} or $a cmp $b} keys %record) { print "$_ reports $record{$_} records.\n"; }
In reply to Re: Array Element Occurence
by turnstep
in thread Array Element Occurence
by entr00pi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |