My immediate thought is that you want this instead since you have never defined the arrays but only array references (I am assuming that you are seeing an error because you have use strict; in your code):
$main::hd=[[]]; $main::a = [0.25]; $main::b = [0.25,0.5]; $main::c = [1,0.75,0.75]; push @{$main::hd}, $main::a; push @{$main::hd}, $main::b; push @{$main::hd}, $main::c;
Edit: it would help a lot to see the actual error message(s) you are seeing.
Edit 2: corrected @{main::hd} to @{$main::hd}.
Edit 3: In more general terms, now that I've had a little bit more Scotch, the overall problem appears to be that he does not full understand the correct syntax for de-referencing. OP defines array references, but is using them as arrays. If OP had used the correct syntax of @{$array_ref} instead of @array_ref (when only $array_ref is defined) then it would have worked as expected.
Understanding sigils, scope and context is crucial to understanding Perl. I think this person will be fine once this is grokked.
In reply to Re: Arrays and Push
by boftx
in thread Arrays and Push
by viored
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |