On Mar 14, Peter Rabbitson said:
sub sub_call {
my ($hashref, $object) = @_;
print "Now working on $object using values\n";
foreach my $key (keys %{${$hahsref}{$object}}) {
print "$key\n"; } }
Simple enough right? What I was asking is how can I get the same result without passing 'abcd' and a reference to the outter hash, but by passing ONLY a reference to the inner hash. Actually the more I think about it the more I figure it can't be done, since references are symbolic and don't carry information about upper (or technically lower) level structures as the outer hash that contains the actual key name... Am I correct? :)
If you're asking how you can pass $hash{abcd} to the function and determine, IN the function, that you're working with the key 'abcd' from the outside hash, there is no way of doing that.
And once again, you've written some round-about referencing code:
# from the first email in this thread another_nasty_sub(\%{$hash{abcd}});
which should just be
another_nasty_sub($hash{abcd});
Then above, you have
foreach my $key (keys %{${$hahsref}{$object}}) {
which looks very messy. It works, but it's got a lot of extra braces. I'd use one of the following:
foreach my $key (keys %{ $$hashref{$object} }) { # or foreach my $key (keys %{ $hashref->{$object} }) {
-- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ % -- Meister Eckhart
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>