Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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 perusing the Monastery: (7)
As of 2014-07-10 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (198 votes), past polls