my @keys = qw(b d a c); my @values = qw(200 100 30 40); my %hash; @hash{@keys} = @values; print Dumper \%hash; #### #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @keys = qw(b d a c); my @values = qw(200 100 30 40); my %hash; @hash{@keys} = @values; print Dumper \%hash; foreach my $key (@keys) { if (exists $hash{$key} ) { print "array element: $key = $hash{$key} inside \%hash\n"; } next; } __END__ $ perl test.pl $VAR1 = { 'a' => '30', 'c' => '40', 'b' => '200', 'd' => '100' }; array element: b = 200 inside %hash array element: d = 100 inside %hash array element: a = 30 inside %hash array element: c = 40 inside %hash