use strict; # important use warnings; # important my %debug; # you rarely want our (or local) test_push(\%debug); print "hey, it works: $_\n" for @{ $debug{stack} # this probably contains our arrayref || [] # but if it doesn't, don't error out please }; sub test_push { # avoid camel case (imo) my ($debug) = @_; push @{ $debug->{stack} }, "lol"; # avoid unnecessary derefs # or my $ar = $debug->{stack}; push @$ar, "lol2"; return; }