Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Array values into hash

by primus (Scribe)
on Feb 09, 2003 at 06:57 UTC ( [id://233850]=note: print w/replies, xml ) Need Help??


in reply to Array values into hash

this should work...

#!/usr/bin/perl use warnings; use strict; my (@lines,%hash); open (IN,"<data.txt") or die "cannot open file for reading: $!"; @lines = <IN>; close (IN) or die "cannot close file: $!"; foreach (@lines) { $_ =~ /(.*)\|(.*)\|/; $hash{$1} = $2; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found