|more useful options|
Re: Hash in Perlby Jim (Curate)
|on Jan 02, 2014 at 08:39 UTC||Need Help??|
As someone else has already pointed out, this isn't a hash. It isn't even Perl. It's just a list of cities and their corresponding countries in English.
I suspect your hash is this:
Did I guess right?
but i want i put like
Once again, this isn't anything in Perl. It's just an English language list of countries and corresponding lists of cities in those countries.
To me, the most natural Perl data structure to use to represent lists of cities by their corresponding countries is a hash of arrays.
So are you asking us how to create this second data structure (a hash of arrays) from the first data structure (a simple hash)?
(This small example isn't Unicode-conformant.)
This Perl script prints…
Finland Helsinki Germany Berlin Germany Frankfurt USA Chicago USA New York USA Washington
The other day in the Chatterbox, I recommended you take a beginning Perl course to learn the rudiments of the language. Have you enrolled in a course yet? If not, you should. (I can see you're in the Chatterbox right now asking how to perform simple text substitution in Perl using substr() instead of the substitution operator s///. This is more evidence that you really need to learn the fundamentals of the Perl programming language either from a good teacher or a good book. Trying to learn it by persistently asking poorly-articulated questions on PerlMonks is very unlikely to succeed.)