Not completely sure what you want here, but you don't get a "mama" because none of the strings you are matching against are isolated by spaces (e.g. you get 1696-R2.2 not 1696) and even if that wasn't a problem, the case matching will fail as well (e.g. 162x <> 162X).
Here's some code that does something - whether it's what you want, or whether it gives you some ideas how to get what you want I leave up to you
my $data_file = 'diana.txt'; my @identifiers = qw(1696 162x 1640); open(FILE, $data_file) || die("Could not open file: $!"); foreach $line(<FILE>){ chomp $line; foreach $identifier(@identifiers){ if($line =~ /$identifier/i){ print "$line match\n"; } } } close FILE;
In reply to Re: How do I extract some records from a textfile
by Melly
in thread How do I extract some records from a textfile
by bory
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |