"sanket vaidya" schreef: > use warnings; > use strict; > my $i=1; > while($i<=10) > { > $_ = "abcpqr"; > $_=~ s/(?=pqr)/$i/; > print "$_\n"; > $i++; > } > [...] > > The expected output is > abc001pqr > [...] > 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??
Why use a regular expression, or even a substitution? perl -Mstrict -Mwarnings -e' printf q{abc%03dpqr%s}, $_, $/ for 1..3; ' abc001pqr abc002pqr abc003pqr -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/