foreach $val (@rel) {
if ($val == 1) {%pg = %pg1}
elsif ($val == 2) {%pg = %pg2}
elsif ($val == 3) {%pg = %pg3}
# etc., etc. and so forth...
Being new to Perl (and more specifically, to using hashes), is there any way
to condense this code so that I don't have to write out a line for every
possible hash?
I've exhausted my resources and am no closer to a solution... Thanks in
advance for any help.
MG
M> I have a series of hashes numbered pg1, pg2, pg3... containing a number of
M> values that I want to be able to access based on the info a user enters.
Almost any time you have a series of variable names, you've got the wrong
data structure already.
You probably want an array of hashes. Not a bunch of individual hashes.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
Forget my last post, please :-)
Michael Ströck