Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Hash and count of data values

by monktim (Friar)
on Aug 18, 2003 at 13:53 UTC ( #284571=note: print w/replies, xml ) Need Help??


in reply to Hash and count of data values

I think you want to store the record read from the file into a scalar, not an array.
use strict; use warnings; my %hash = (); while (<DATA>) { chomp; $hash{$_}++; } foreach (keys %hash) { print "$_ appears $hash{$_} time(s).\n"; } __DATA__ 123 56 123 56 234 45 123 56 678 93 678 93

Replies are listed 'Best First'.
Re: Re: Hash and count of data values
by Anonymous Monk on Aug 18, 2003 at 14:18 UTC
    I cant believe how many answers I got. Thanks!!!
    It now prints what I wanted.
    Thank you to all who helped me!!!!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-12-01 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?