Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Preceptor's scratchpad

by Preceptor (Deacon)
on Jun 03, 2004 at 19:32 UTC ( #360399=scratchpad: print w/replies, xml ) Need Help??

#!/usr/bin/perl use strict; use warnings; use autodie; #Get the filename from the first argument. my ($filename) = @ARGV; #open it to read it. open( my $input_data, "<", $filename ); #set up somewhere to store our count. my %word_count; #cycle through one line at a time. while (<$input_data>) { chomp; #take each line, split it by spaces and #count the number of occurances foreach my $word (split) { $word_count{$word}++; } } #print the results. Sort %word_count into count order. #(Descending) and print. foreach my $word ( sort { $word_count{$b} <=> $word_count{$a} } keys %word +_count ) { print "$word = $word_count{$word}\n"; }
Log In?

What's my password?
Create A New User
[marto]: good morning all
[Corion]: Hi marto!
[Corion]: I just found out that in $current_top_prior ity_project , the part I am in is not even in the top three worries. That's somewhat bad, not because I'm happy with being a top worry but because that means that I don't even know how bad the rest ...
[Corion]: ... of the situation is :-)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2017-07-26 08:05 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (385 votes). Check out past polls.