gdolph has asked for the wisdom of the Perl Monks concerning the following question:
I have a multi-dimentional data structure, a mix of hashes and arrays. An example would be $$hash{domains}{sub1}{sub2}. If I want to get something out of it I know all I need to do is $hash->{$domain}{$var1}{$var2}. However, I want to pass {$var1}{$var2} to a subroutine so I can:
foreach my $domain (sort {$a cmp $b} keys %{$hash}) { my $value = $hash->{$domain}$test; }
where the variable $test is actually the code {$var1}{$var2}. I've tried my $test = "{var1}{$var2}" but I get an unblessed reference error.
How do I do I get perl to look at $test not as a the string "{$var1}{$var2}" but as the perl code {$var1}{$var2} ? Can I do this at all?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: unblessed reference problem
by Corion (Patriarch) on Mar 26, 2010 at 11:08 UTC | |
by Anonymous Monk on Mar 26, 2010 at 11:13 UTC | |
by gdolph (Novice) on Mar 26, 2010 at 11:19 UTC | |
by Corion (Patriarch) on Mar 26, 2010 at 23:20 UTC | |
by Anonymous Monk on Mar 26, 2010 at 11:21 UTC | |
by gdolph (Novice) on Mar 26, 2010 at 11:23 UTC | |
|
Re: unblessed reference problem
by james2vegas (Chaplain) on Mar 26, 2010 at 11:36 UTC | |
by gdolph (Novice) on Mar 26, 2010 at 11:51 UTC | |
by almut (Canon) on Mar 26, 2010 at 12:12 UTC | |
by gdolph (Novice) on Mar 26, 2010 at 12:22 UTC | |
by Anonymous Monk on Mar 26, 2010 at 11:55 UTC | |
|
Re: unblessed reference problem
by roboticus (Chancellor) on Mar 26, 2010 at 12:03 UTC | |
by roboticus (Chancellor) on Mar 26, 2010 at 12:09 UTC | |
by chromatic (Archbishop) on Mar 26, 2010 at 18:55 UTC | |
by gdolph (Novice) on Mar 26, 2010 at 12:13 UTC |