Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Count and List Items in a List

by Perl Mouse (Chaplain)
on Nov 01, 2005 at 15:24 UTC ( #504603=note: print w/ replies, xml ) Need Help??


in reply to Count and List Items in a List

use strict; use warnings; my %count; open my $data, "<", "userstab.txt" or die "open: $!"; open my $result, ">", "results.txt" or die "open: $!"; while (<$data>) { chomp; my $zapschool = (split /\t/)[4]; $count{$zapschool}++; print $result "$zapschool\n" if /zaps/; } close $data or die "close: $!"; close $result or die "close: $!"; while (my ($school, $count) = each %count) { printf "%s appears %d times\n", $school, $count; }
Perl --((8:>*


Comment on Re: Count and List Items in a List
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://504603]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-07-26 11:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (176 votes), past polls