On Fri, 8 Feb 2002, Balint, Jess wrote: > Hello all. I am getting wierd errors on the following piece of code. > > > 95: for( 0..$#vars ) { > 96: if( defined( $vars[$_] ) ) { > 97: $freqidx{$key}[$_] += $fields[$vars[$_]]; > 98: } > 99: } > > @vars are all numberic values and some values of @fields are "". Can > $fields[$n] be defined as ""? Shouldn't perl just add "" as 0? The errors > are as follows: > > Argument "" isn't numeric in add at ../20020128/pasummary.pl line 96, > <INFILE> chunk 4258. > Argument "" isn't numeric in add at ../20020128/pasummary.pl line 96, > <INFILE> chunk 17733.
You should probably make those "" explicitly into 0 values. If you are using the 'strict' pragma, this will throw an error. You can make sure it is a number by doing something like: $fields[$vars[$_] ||= 0; Or, better yet, when creating the array, make 0 the default value, not "" (both will yield boolean false when used in an expression). -- Brett http://www.chapelperilous.net/ ------------------------------------------------------------------------ Your password is pitifully obvious. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]