On Sunday 23 May 2010, Rob Dixon wrote:
> I think you may have simplified the problem you are facing a little too 
> much, but the code below does what you ask for. If, as I suspect, this 
> solution is not applicable to your real data, then please try to 
> describe the problem rather than coding up bits of Perl and leavng us to 
> guess what the data is like.
> 
> HTH,
> 
> Rob
> 
> 
> use strict;
> use warnings;
> 
> my $data = 'abcdpqrsxyz';
> 
> my %matches = $data =~ /(ab(cd))((pq)rs)/;
> 
> foreach my $key (keys %matches) {
>    print "$key => $matches{$key}\n";
> }
> 
> __END__
> 
> *OUTPUT*
> 
> pqrs => pq
> abcd => cd
> 

Thanks Rob for your answer. It looks like you really understood what I was 
trying to get, but I missed an important point in my question that they were 
two separate regex expressions. Sorry for that!

my $rx1 = qr{ ab(cd) }mx;
my $rx2 = qr{ (pq)rs }mx;

So could you tell me how would you write the statement now? 

-- 
Regards,
Akhthar Parvez K
http://tips.sysadminguide.com/
UNIX is basically a simple operating system, but you have to be a genius to 
understand the simplicity - Dennis Ritchie

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to