$VAR1 = [ [ '95', undef ], [ '100', '0' ] [ '105', '1' ], [ '110', '1' ] ]; #### !/usr/bin/perl -w use strict; use Data::Dumper; my @one = qw(95 undef); my @two = qw(100 2); my @three = qw(105 undef); my @four = qw(100 2); my @array = \@one; push @array, \@two; push @array, \@three; push @array, \@four; print Dumper @array; my %hash; foreach my $ary ( @array ) { if ( @$ary[1] eq undef ) { @$ary[1] = '0' } $hash{@$ary[1]} = push @$ary[0]; } print Dumper %hash;