in reply to pushing hash values to an array

I am not sure what you are trying to do there, but you can start by cleaning up your code. Here is a sample attempt:
use strict; use warnings; my %spelling_of = ( 1 => 'one', 2 => 'two', 3 => 'three', ); my @integers = (1, 2); foreach my $key (sort keys %spelling_of) { push @integers, $spelling_of{ $key }; } printf qq(%s\n), join q(, ), @integers; @integers = (3, 4, 5); my $spelling_href = \%spelling_of; foreach my $key (sort keys %$spelling_href) { push @integers, $spelling_href->{ $key }; } printf qq(%s\n), join q(, ), @integers;
that prints:
1, 2, one, two, three 3, 4, 5, one, two, three
which is probably not what you wanted. I have the feeling that you want to print the spelling of the integers in the array, if they are available. If that is the case, then the following may give you some ideas:
use strict; use warnings; my %spelling_of = ( 1 => 'one', 2 => 'two', 3 => 'three', ); my @integers = (1, 2); my @spellings = (); foreach my $integer (@integers) { my $spelling = $spelling_of{ $integer }; push @spellings, (defined( $spelling ) ? $spelling : q(?)); } printf qq(%s => %s\n), join( q(, ), @integers), join( q(, ), @spellings), ; @integers = (3, 4, 5); @spellings = (); my $spelling_href = \%spelling_of; foreach my $integer (@integers) { my $spelling = $spelling_href->{ $integer }; push @spellings, (defined( $spelling ) ? $spelling : q(?)); } printf qq(%s => %s\n), join( q(, ), @integers), join( q(, ), @spellings), ; __END__
You may have presumed that once you define a hash named %h, then a scalar named $h is automatically created and its value set to \%h, but that is not the case. You have to do that yourself.

Make sure your code compiles and runs before you post it. It appears that the use strict; and use warnings; bits were added as accessories-after-the-fact. HTH.

Update: Added <readmore>