You took some extra references; I removed some backslashes: seem method 'a' below.
(If you really had to convert the substring \$hash{\$x}{$y}{'value'} to a reference, you'd need to use eval()'. But, I think you ought to look at method 'b' below ... $x = 'xval'; $y = 'yval'; $hash{$x}{$y}{'value'} = 'worked'; $hash{$x}{$y}{'value2'} = 'not worked'; # method a $hashfmt{'1'} = "abc, 123, $hash{$x}{$y}{'value'}, xyz, 345, $hash{$x}{$y}{'value2'}" ; @values = split(/, |,/ ,$hashfmt{'1'}) ; # note I switch alternatives print "a: $values[2], $values[5]\n"; # method b @values = ('abc', 123, $hash{$x}{$y}{'value'}, 'xyz', 345, $hash{$x}{$y}{'value2'}); print "b: $values[2], $values[5]"; ... prints a: worked, not worked b: worked, not worked > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of Ed > DeBus > Sent: Tuesday, December 04, 2001 2:27 AM > To: [EMAIL PROTECTED] > Subject: dynamic variable evaluation > > > > Given the following scenario, is there a clean way to perform variable > substitution.... > > First, we have a 3 dimensional hash: > > $hash{$x}{$y}{'value'} = "it worked" ; > $hash{$x}{$y}{'value2'} = "didn't work" ; > > > And another "reference" hash (nothing to do with perl ref's, but > rather for > building an array dynamically) > > $hashfmt{'1'} = "abc, 123, \$hash{\$x}{$y}{'value'}, xyz, 345, > \$hash{\$x}{\$y}{'value2'}" ; > > > Now build an array dynamically using format defined by the > "reference" hash. > > @values = split(/,|, / ,$hashfmt{'1'}) ; > > $count=1 ; > foreach $item (@values) { > ?????< do what here> if ($count % 3 == 0) ; > print "Item = [$item]\n" : > $count++ ; > } > > > The problem I have is getting every 3ed item in the array (array position > 2,5, etc.) to evaluate and return a value of "it worked" or "didn't work". > The reference hash format(s) are configured when the script starts and > remain static from that point forward. It's probably obvious, but keys to > the 1st and 2nd dimensions of the "reference" hash are passed as variables > from a calling subroutine. Probably important to also mention that the > values for the 1st and 2nd keys of the 3 dimensional hash can/do change > frequently. > > Any help/idea's appreciated.... > > Ed > > _______________________________________________ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users > > _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users