in reply to Re: Reporting entries in a file
in thread Reporting entries in a file

Thank you, a hash is exactly what I needed, not an array.
I saw an example online, and modified it a tad:
#!/usr/bin/perl while (<>) { @words = split(/\n+/); foreach $word (@words) { $count{$word}++; } } foreach $word (sort by_count keys %count) { print "$word \: $count{$word}\n"; } sub by_count { $count{$b} <=> $count{$a}; }

Replies are listed 'Best First'.
Re^3: Reporting entries in a file
by alexm (Chaplain) on May 30, 2008 at 22:26 UTC
    @words = split(/\n+/);

    I guess you meant: @words = split(/\s+/);

Re^3: Reporting entries in a file
by SkullOne (Acolyte) on May 30, 2008 at 22:13 UTC
    Correction, the hash would've worked fine, but ended up using an array again.