in reply to converting strings to ints
The warning is there to help you. If you know you are going to be trying to treat null strings as numbers, turn it off:
use strict; use warnings; use 5.010; my @arr1 = ("1", "", ""); my @arr2 = ("", "3", "4"); for my $index (0 .. 2) { no warnings 'numeric'; say $arr1[$index] + $arr2[$index]; } __END__ c:\test>junk 1 3 4
And you can prevent the used only once warning, by using them twice. Eg. add a line $a = $b;.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: converting strings to ints
by AnomalousMonk (Archbishop) on Mar 20, 2010 at 20:20 UTC | |
by BrowserUk (Patriarch) on Mar 20, 2010 at 21:33 UTC | |
Re^2: converting strings to ints
by Hue-Bond (Priest) on Mar 20, 2010 at 16:35 UTC | |
by BrowserUk (Patriarch) on Mar 20, 2010 at 17:20 UTC | |
by Hue-Bond (Priest) on Mar 20, 2010 at 20:49 UTC |