http://www.perlmonks.org?node_id=1033964


in reply to how does perl handle variables

"in this case it should ideally throw some error but it just considers > a,b,c... as 0 ? why does it do that"

Adding use strict; use warnings; is advisable. See strict, warnings:

#!/usr/bin/perl use strict; use warnings; my @a=qw( 1 2 3 4 a b c g f); my $s=0; foreach my $i(@a){ $s+= $i; print "i: $i - s: $s\n"; } print $s;

shows:

D:\>perl derp.pl i: 1 - s: 1 i: 2 - s: 3 i: 3 - s: 6 i: 4 - s: 10 Argument "a" isn't numeric in addition (+) at derp.pl line 10. i: a - s: 10 Argument "b" isn't numeric in addition (+) at derp.pl line 10. i: b - s: 10 Argument "c" isn't numeric in addition (+) at derp.pl line 10. i: c - s: 10 Argument "g" isn't numeric in addition (+) at derp.pl line 10. i: g - s: 10 Argument "f" isn't numeric in addition (+) at derp.pl line 10. i: f - s: 10 10