Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: string match using with an N in any position

by salva (Abbot)
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 having an uproarious good time at the Monastery: (14)
As of 2015-07-07 18:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls