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