in reply to push to a referenced array
sub ref_push { if ( !$_[0] ) { $_[0] = [ @_[1..$#_] ]; } else { push @{$_[0]}, @_[1..$#_]; } } [download]
Not safe enough:
sub ref_push { if (ref $_[0] eq "ARRAY") { push @{$_[0]}, @_[1..$#_]; } elsif (ref $_[0]) { warn "Cannot push onto non-ARRAY ref"; } elsif (!defined $_[0]) { $_[0] = [ @_[1..$#_] ]; else { warn "Cannot push: Variable already defined as something else" +; } } # ref_push [download]