Annemarie has asked for the wisdom of the Perl Monks concerning the following question:
A sample testfile looks like this:#! /usr/bin/perl $template="A2x2A3"; for $mag (50..90){ $abumax[$mag]=1; for $abu (1..100){ $bin[$mag][$abu]=0; } } while (<>){ ($mag,$abu)=unpack($template,$_); $bin[$mag][$abu]++; $abumax[$mag]=$abu if ($abu >$abumax[$mag]); } for $mag (50..90){ for $abu (1..$abumax[$mag]){ if ($bin[$mag][$abu] !=0){ printf"%2s %3s %3s\n", $mag, $abu, $bin[$mag][$abu]; } } }
The output looks like this:50 1 50 2 53 5 54 2 50 2 53 5 54 2 50 2 53 5 54 2 64 5
50 1 1 50 2 3 53 5 3 54 2 3 64 5 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Counting frequency of occurrence - what am I doing?
by ikegami (Patriarch) on Mar 08, 2005 at 20:25 UTC | |
|
Re: Counting frequency of occurrence - what am I doing?
by RazorbladeBidet (Friar) on Mar 08, 2005 at 20:11 UTC | |
by Annemarie (Acolyte) on Mar 08, 2005 at 20:44 UTC | |
by RazorbladeBidet (Friar) on Mar 08, 2005 at 20:47 UTC | |
|
Re: Counting frequency of occurrence - what am I doing?
by trammell (Priest) on Mar 08, 2005 at 20:12 UTC | |
|
Re: Counting frequency of occurrence - what am I doing?
by Joost (Canon) on Mar 08, 2005 at 20:13 UTC | |
|
Re: Counting frequency of occurrence - what am I doing?
by legato (Monk) on Mar 08, 2005 at 21:53 UTC | |
|
Re: Counting frequency of occurrence - what am I doing?
by Zaxo (Archbishop) on Mar 08, 2005 at 20:14 UTC |