This worked for me:

$increment = 10;
$string = 'This is a 10 string with 124 in it to test 50';
print "before: $string\n";
$string =~ s/(\d+)/$1 + $increment/ge;
print "after : $string\n";

Basil



"Sumit" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]

12/05/2003 02:56 PM

       
        To:        <[EMAIL PROTECTED]>
        cc:        
        Subject:        evaluate perl code

       


Hi,
I have a regex in which I want to increment all matching numbers by some value. Something like
$increment = 10
$string =~ s/(\d+)/$1+ $increment/g;
 
I tried the /e modifier (to evaluate perl code on the RHS of substitution)  but Perl complains on that
and gives me a compile error.
 
Any hints on this?
 
Thanks.

Reply via email to