snowyy has asked for the wisdom of the Perl Monks concerning the following question:

I want the value of the first element in the first array, what is wrong with my code?

$first = $stat_ref[0][0]; # $stat_ref is a hard reference to an array of arrays.
Tried this too but it didn't work.
$first = $$stat_ref->[0][0];

Replies are listed 'Best First'.
Re: Hard Reference
by chromatic (Archbishop) on May 19, 2001 at 07:59 UTC
    Your first example doesn't dereference $stat_ref. Your second example dereferences it twice. You have two options:
    $first = $stat_ref->[0][0]; # or $first = $$stat_ref[0][0];
    I think this is documented in perlreftut. It's a hard concept to grok the first time around. I stumbled over it for a couple of weeks, myself.