Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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: (11)
As of 2014-12-19 13:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (83 votes), past polls