Re: adding strings, not concatenating them
- From: Joe Smith <joe@xxxxxxxxx>
- Date: Wed, 15 Feb 2006 10:39:11 -0800
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
.
- Follow-Ups:
- Re: adding strings, not concatenating them
- From: Stan Horwitz
- Re: adding strings, not concatenating them
- References:
- adding strings, not concatenating them
- From: Stan Horwitz
- adding strings, not concatenating them
- Prev by Date: adding strings, not concatenating them
- Next by Date: Re: adding strings, not concatenating them
- Previous by thread: adding strings, not concatenating them
- Next by thread: Re: adding strings, not concatenating them
- Index(es):