"Amit Koren" schreef:
> $string="blah 10 20";
> I need to add 5 to the 10, and add 7 to the 20.
#!/usr/bin/perl
use strict;
use warnings;
my %add = (
10 => 5,
20 => 7,
);
while ( ) {
s/ ( [0-9]+ ) / exists($add{$1}) ? $add{$1} : $1 /xge;
print;
}
__D
Amit Koren wrote:
Hi all.
Hello,
Is there a way to insert an arithmetic calculation into a substitute
operation, keeping all "non-integers" AS THEY WERE ?
Example:
$string="blah 10 20";
I need to add 5 to the 10, and add 7 to the 20.
So after the substitution, $string will contain: "bl