in reply to Re: Re: Re: Summing the elements of multiple arrays into a new array
in thread Summing the elements of multiple arrays into a new array

If you have -w or use warnings turned on, you'll get the following error when the arrays aren't the same size:
Use of uninitialized value in addition (+)
Which is the most irritating non-warning that perl can toss at you. Its complaining about something like (3 + undef) which is a perfectly valid Perl expression, so I wish perl wouldn't yell at me for using it.

p.s. my solution above also spits out the same spurious warnings...

-Blake

Replies are listed 'Best First'.
(ichimunki) re x 5: Summing the elements of multiple arrays into a new array
by ichimunki (Priest) on Nov 02, 2001 at 03:09 UTC
    It's a good warning in the sense that sometimes you will have variables that you intended to set get into your assignments still undefined and this lets you know, in a non-fatal way, that something may be wrong.

    On the other hand, you can do like the Slashdot crew and customize a SIGWARN callback to muffle this output.
      No need to go through all that on current versions of perl.... If I know I'm in a 5.6.0 or newer perl environment, the first few lines of my code are usually:
      #!/usr/bin/perl -T use warnings; no warnings "uninitialized";
      I find that this bounds me enough to catch my screw-ups, but not enough to inhibit my coding style..

      -Blake