Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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 musing on the Monastery: (7)
As of 2015-05-23 09:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    In my home, the TV remote control is ...









    Results (466 votes), past polls