Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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); }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://910225]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2018-03-18 01:24 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (228 votes). Check out past polls.