my %file1_row_for; while (my $input = ){ # only grab column 2 my ( undef, $id ) = split /;/, $input; # add this line to the array of data for this key push @{ $file1_row_for{$id} } = $input; } #### print join ';', @{ $file_row_for{$id} } if scalar @{ $file_row_for{$id} }; #### perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(join(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'