in reply to changing a string to a numeric variable
There are probably nicer ways to solve this, but this seems to work ;)
$a = "word 15,000 word word 20,000"; @b = split " ", $a; $b[1] =~ s/,//g; $b[4] =~ s/,//g; print $b[1] + $b[4]."\n";
This will result in "35000"
HTH
Update: It'd of course be nicer (even in my messy example) to use a sub routine for this, which returns the commaless values ...
|
|---|