peterb has asked for the wisdom of the Perl Monks concerning the following question:
perl v5.8.8, use strict, use diagnostics
I hava an array of hashes that match to database fields
I would like to substitute the hash name with$customer->[0]{_name} $customer->[0]{_address1} $customer->[0]{_address2}
for looping purposes, but it doesn't work.my $i = 1; $varname = "_address" . $i; print "Customer Address", $customer->[0]{$varname};
does not work. I get the an uninitialized value error (for both tries).print "Customer Address", $customer->[0]{${varname}};
I could put the hashes into address array and then loop through those but laziness makes me think perl can do it...
Thank you,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash name variable substitution
by Errto (Vicar) on May 21, 2007 at 20:13 UTC | |
by peterb (Novice) on May 21, 2007 at 20:24 UTC | |
|
Re: Hash name variable substitution
by thezip (Vicar) on May 21, 2007 at 20:28 UTC | |
|
Re: Hash name variable substitution
by shmem (Chancellor) on May 21, 2007 at 20:33 UTC |