perl ref to hash with refs in it (how to get what's being referenced).

I have a reference to a hash that contains some references. I was just wondering if there was a more simplistic Way of dereferencing the contained references without having to assign them to another reference like this:

my $href = shift; #some hash
my $temp = $href->{element};
print join('',@$temp);

What I want is to avoid copying the reference into $temp and then getting the info it's referencing. I don't think @$href->{element} would work seeing that $href is a reference itself. I'm just all for concise code. If anyone knows of a proper way to do this, I'd appreciate it.

Thanks in advance.

I think you can wrap @ around a statement like @{ ... }

You can write it like this -

my $href = shift; #some hash
print join('', @{$href->{element}});

Or like this -

my $href = shift; #some hash
print join('', @{$$href{element}});

An example follows:

$
$ perl -le '@a = qw(1 10 100); $x{1} = \@a; $href=\%x; print join(" ", @{$href->{1}})'
1 10 100
$
$
$ perl -le '@a = qw(1 10 100); $x{1} = \@a; $href=\%x; print join(" ", @{$$href{1}})'
1 10 100
$
$

tyler_durden

To dereference a hash containing references to to other hashes do this...

$href->{key1}{key2};

now you wont need $temp