> my %hash=();
> my $mykey="key";
> my $myval1=$myval2="test";
>
> #store data in a hash of arrays
> $hash{$mykey}=[$myval1, $myval2];
>
> Later on I want to retrieve the data and I have to do it like:
>
> $myval1=$hash{$mykey}[0];
> $myval2=$hash{$mykey}[1];
>
> There are a lot of array values and I am looking for a more
> elegant way to retrieve data, something like ($myval1,
> $myval2)=$hash{$mykey}; (doesnt work)
That does not work like you expect because you are assigning the array reference tp
$myval1
Try :
my($myval1,$myval2) = @{$hash{$mykey}};
One elegant (Mmm maybe not "elegant" ;p ) way is to just use the $hash{$mykey}[0]
version and not
muck up the name space and lengthen your code declaring tons of variables.
Just a thought
DMuey
>
> I'm sure I am missing something embarrassingly simple. Any
> help would be appreciated.
>
> Phillip
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]