my ($num) = (/ (\d+) /); my $newnum = $num + $some_other_number; s/ $num / $newnum /;