Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Constructing a hash

by danwoods (Initiate)
on Mar 17, 2011 at 15:02 UTC ( [id://893780]=note: print w/replies, xml ) Need Help??


in reply to Constructing a hash

Yeah, like the other people said, your code has some serious fundamental problems... May need to hit an intro to perl tutorial or something... But, for now:
use strict; use warnings; use Data::Dumper; open (FH, "<data.txt"); my (%hash); while (my $line = <FH>) { my $key = lc($line); $hash{$key} = $line; } close(FH); open (FH, ">hash.txt"); print FH Data::Dumper->Dump([%hash]); close(FH);
That should work for you.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-25 14:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found