You should be analyzing your parameters before you start your search to make life easier, e.g. like this:
use strict; use warnings; sub name_search { join '', map {$_->[0]} grep { 0<=index $_[0], $_->[1] and 0<=index $ +_[0], $_->[2] } @{$_[1]}; } my @criteria; my $letter = 65; push @criteria, [ chr( $letter++ ), splice @ARGV, 0, 2 ] while @ARGV > += 2; print name_search 'John Smith', \@criteria; print "\n";
Also, have a look at join. You could write, assuming you open your output file before the loop:
while(<$data>) { chomp; my @line = split /\t/; my $found_tag = name_search $line[0], \@criteria; print OUT1 join( "\t", $found_tag, @line[0..13] )."\n" if $found_tag +; } close $data;
In reply to Re: Need Speed:Search Tab-delimited File for pairs of names
by hdb
in thread Need Speed:Search Tab-delimited File for pairs of names
by mnnb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |