in reply to Counting frequency of occurrence - what am I doing?
Your arrays are rather sparse. You might want to use hashes instead. It would also rid you of the need of the (possibly arbitrary) limits of 50..90 and 1..100. It wouldn't hurt to use strict and warnings, either.
#!/usr/bin/perl use strict; use warnings; my %bin; my $mag; my $abu; while (<>) { ($mag, $abu) = split(/\s+/, $_); $bin{$mag}{$abu}++; } foreach $mag (sort { $a <=> $b } keys %bin) { foreach $abu (sort { $a <=> $b } keys %{$bin{$mag}}) { printf("%2s %3s %3s\n", $mag, $abu, $bin{$mag}{$abu}); } }
|
|---|