# 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.'); my @givenlines = <$givenh>; my @totallines = <$totalh>; foreach my $givenl (@givenlines){ chomp $givenl; print $givenl; print ' '; foreach my $totall (@totallines){ chomp $totall; if ($totall =~ /$givenl/) { my @array = split(/ /, $totall); print $array[0]; print ' '; } } print "\n"; }