Perl is pretty nice about default values:
: jmglov@laurana; perl -e \'@foo; printf \"%d\\n\", $foo[123]\' 0 : jmglov@laurana; perl -e \'%foo; printf \"%d\\n\
If you're dealing with integers you can call to_i:
to_i
foo = [] foo[100] #=> nil foo[100].to_i #=> 0 foo[100] = 3 foo[100] #=> 3
UPD
Oh, I didn't read all topic :)
so you can use this:
foo.inject{|a,b| a.to_i + b.to_i }
which, actually, not the smartest one