# Code to create gmt files use strict; use warnings; my ($given, $total) = @ARGV; open (my $givenh, $given) or die('Given.'); open (my $totalh, $total) or die('Total.'); while (my $givenl = <$givenh>){ chomp $givenl; print $givenl; print ' '; my @garray = split(/ /,$givenl); while (my $totall = <$totalh>){ chomp $totall; if ($totall =~ /$garray[0]/) { my @array = split(/ /, $totall); print $array[0]; print ' '; } } print "\n"; }