Re: adding strings, not concatenating them



Stan Horwitz wrote:

$total = $total + $extracted_variable;

Let's say $total is initialized to a value of 10 and $extracted_variable is "900".

I want the result to be 910. I do not want a result of 90010.

How do I do that? My current attempts all result in errors such as

isn't numeric in addition (+) at

Oh, really?

You need to post a short but complete perl program that
demonstrates this problem before we can help you. I cannot
reproduce the problem from your description.

use warnings;
$stuff=" 900xyz";
$extracted_variable = substr $stuff,0,8;
$total = 10;
print "Before: total='$total' extracted_variable='$extracted_variable'\n";
$total = $total + $extracted_variable;
print "After: total='$total'\n";

-Joe
.