Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: read the file and assign each line to a hash????

by b10m (Vicar)
on Sep 08, 2006 at 12:48 UTC ( #571952=note: print w/ replies, xml ) Need Help??


in reply to read the file and assign each line to a hash????

my %hash; open FH, "<", "/path/to/file" or die "Can't open file: $!"; while(<FH>) { chomp; if($_ =~ m/^([^:]+): (.*)$/) { $hash{$1} = $2; } } close FH;
--
b10m

All code is usually tested, but rarely trusted.


Comment on Re: read the file and assign each line to a hash????
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2014-10-25 03:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (141 votes), past polls