Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Syntactic Confectionery Delight
 
PerlMonks  

Re: string match using with an N in any position

by salva (Monsignor)
on Nov 18, 2011 at 07:34 UTC ( #938748=note: print w/ replies, xml ) Need Help??


in reply to string match using with an N in any position

If the matching strings are all of the same length:

my %match = map { $_ => 1 } qw(GCGAT CACGT); while (<>) { my $line = $_; s/N//; # remove the first N in the string print "match: $line" if $match{substr($_, 0, 5)} }
otherwise, if they have different lengths:
my $pattern = join('|', qw(GCGAT CACGT)); $pattern = qr/^(?:$pattern)/; while (<>) { my $line = $_; s/N//; # remove the first N in the string print "match: $line" if $_ =~ $pattern; }


Comment on Re: string match using with an N in any position
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://938748]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2014-04-19 18:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (483 votes), past polls