#! /usr/bin/perl use strict; use warnings; my $id_file = '/path/to/file/with/ids.txt'; my $fasta_file = '/path/of/fasta/file.fasta'; open(my $fh, "<$id_file") or die $!; my @ids = <$fh>; close $fh; { local $/ = "\n>"; open(my $fh, "<$fasta_file") or die $!; while(my $entry = <$fh>){ print $entry if(grep{$entry =~ /\Q$_\E/}@ids); } }
In reply to Re: pattern matching and array comparison
by reneeb
in thread pattern matching and array comparison
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |