in reply to Arrays and Push

Instead of push @{main::hd}, [@main::a]; you either wanted to write push @{main::hd}, $main::a; or push @{main::hd}, [@$main::a]; If you had used use strict; use warnings Perl would have told you that @main::a is an undefined value. Only the scalar (reference to an array) $main::a is defined by you (in line 2).

Greetings,
Janek

Replies are listed 'Best First'.
Re^2: Arrays and Push
by boftx (Deacon) on Apr 03, 2014 at 05:35 UTC

    I suspect that he did in fact have use strict; in place and is seeing such an error message. I say this because there is little or no reason to ever use fully qualified variable names unless one does not fully understand how to use my $variable (or our $variable) when use strict; is in effect.

    On a side-note, it is a pleasant surprise to see someone who knows about the "main" namespace. :)

    It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.