Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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]
[Eily]: hu, it came with 5.22 ...
Discipulus win32 is the vietnam of envs..
[Eily]: what's your perl version Discipulus ?
[karlgoethebier]: Eily, Discipulus : IMHO it's worth to ask in SoPW
[Discipulus]: dunno, it is the damned doublequote issue, i think
[karlgoethebier]: Eily: ah, i have v5.24.1

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2017-07-21 08:41 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (319 votes). Check out past polls.