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

Re: Can not print hash element

by poolpi (Hermit)
on Sep 23, 2008 at 10:43 UTC ( [id://713191]=note: print w/replies, xml ) Need Help??


in reply to Can not print hash element

Skipping duplicate cities and regexp

#!/usr/bin/perl -w use strict; use Data::Dumper; my $country; # Hash ref ;) my $sep = q{,}; while (<DATA>) { chomp; next if /\A\z/; /\s* (.+) \s* $sep \s* (.+) \s*/msx; next unless defined $1 and defined $2; grep { /$1/i } @{ $country->{$2} } or push @{ $country->{$2} }, $1; } print Dumper $country; __DATA__ Chicago, USA Frankfurt, Germany Berlin, Germany Washington, USA Helsinki, Finland Berlin, Germany New York, USA Freetown, Sierra Leone

hth,
PooLpi

'Ebry haffa hoe hab im tik a bush'. Jamaican proverb

Log In?
Username:
Password:

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

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

    No recent polls found