"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 ( <DATA> ) {
s/ ( [0-9]+ ) / exists($add{$1}) ? $add{$1} : $1 /xge;
print;
}
__DATA__
blah 10 37 20 blah
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
