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


in reply to Some "combined assignment operators" are exempt from "uninitialized value" warning. Is it documented anywhere?

When I was new to Perl uninitialized values were the bane of my existence. Many traps are eliminated simply by initializing all variables. It's useful to init strings to '' and numbers to 0 so they can be freely checked and used after declaration without having to worry about init errors. If there's a problem with the program it will display the init values instead of crashing with an error. My preference is always: not to crash.
my $value; # Error if condition fails. my $value = ''; # Empty if condition fails. if (condition) { $value += 'something' } print "The value is $value";
  • Comment on Re: Some "combined assignment operators" are exempt from "uninitialized value" warning. Is it documented anywhere?
  • Download Code