Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: creating a hash from a text file.

by Generoso (Prior)
on Jul 27, 2010 at 15:19 UTC ( [id://851561]=note: print w/replies, xml ) Need Help??


in reply to creating a hash from a text file.

Try this see if it helps.

#!/usr/bin/perl -w # gene.plx # use strict; my %hash = (); while (<DATA>) { chomp($_); my ($dept,$email)=split(/:/); $hash{ $dept } .= $email.','; } s/,\z// for values %hash; print "\n"; while ( my ($key, $value) = each(%hash) ) { print "$key => $value\n"; } print "size of hash: " . keys( %hash ) . ".\n"; print '-' x (60),"\n"; __DATA__ 6:car 1:human 3:fruits 9:flower 2:flower 5:human

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-19 22:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found