Sumit wrote:
> 
> 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.

Hi.

I'm not sure what you're doing wrong, but the following
program works fine!

HTH,

Rob



use strict;
use warnings;

my $increment = 10;
my $string = '1 2 3 4 5 22 55 77';

$string =~ s/(\d+)/$1 + $increment/eg;

print $string, "\n";

**OUTPUT

11 12 13 14 15 32 65 87


_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to