Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Count and List Items in a List

by Perl Mouse (Chaplain)
on Nov 01, 2005 at 15:24 UTC ( [id://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:>*

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-28 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found