Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: pattern match with different sets.

by ig (Vicar)
on Jun 17, 2011 at 17:35 UTC ( #910225=note: print w/ replies, xml ) Need Help??


in reply to pattern match with different sets.

It would be easier to help you if you posted actual code rather than the vague description "and comparing the $m ==$m1 and also /(\w+)(a|b|c). and comparing the $1 of one sample with the other".

It's only a guess but maybe something like the following would do what you want.

use strict; use warnings; my @samples = qw( PD4005a PD4005b PD4005c WGA_PD4005a WGA_PD4005b WGA_PD4005c DIFFERENT ); foreach my $s1 (@samples) { foreach my $s2 (@samples) { next if(compare($s1,$s2)); print "$s1 - $s2\n"; } } sub compare { my ($s1, $s2) = @_; if($s1 =~ m/^(WGA_)?PD(\d+)[abc]$/) { my $n1 = $2; if($s2 =~ m/^(WGA_)?PD(\d+)[abc]$/) { return($n1 == $2); } } return(0); }


Comment on Re: pattern match with different sets.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2015-07-04 19:21 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 (60 votes), past polls