Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Creating hash Array

by brsaravan (Scribe)
on Oct 20, 2008 at 14:19 UTC ( [id://718233]=note: print w/replies, xml ) Need Help??


in reply to Creating hash Array

I don't think you are creating hash array here, instead you are just reading the file content and creating a hash. Moreover use "chomp" whenever you are using file handles.
use strict; use warnings; my %href; my $fn = <>; open(FH, "$fn") || die "Cannot open file"; while (<FH>) { chomp($_); $href{$1} = $2 if $_ =~ /(\S+)\s+(\S+)/; } while (my ($key, $value) = each(%href)) { print $key. ", ". $value."\n"; }

Log In?
Username:
Password:

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

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

    No recent polls found