Regex help?

[email protected] ("sanket vaidya")
Newsgroups perl.beginners
Organization Patni Computer Systems Limited
Message-ID <[email protected]>
HI all,

 

Kindly go through the code below.

 

use warnings;

use strict;

my $i=1;

while($i<=10)

{

$_ = "abcpqr";

$_=~ s/(?=pqr)/$i/;

print "$_\n";

$i++;

}

 

Output:

abc1pqr

abc2pqr

abc3pqr

abc4pqr

abc5pqr

abc6pqr

abc7pqr

abc8pqr

abc9pqr

abc10pqr

 

The expected output is

 

abc001pqr

abc002pqr

abc003pqr

abc004pqr

abc005pqr

abc006pqr

abc007pqr

abc008pqr

abc009pqr

abc010pqr

 

Can any one suggest me how to get that output using regex. i.e. Can this
happen by making change in regex I used in code??
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.