in reply to Re: Return array from sub or return empty array (updated)
in thread Return array from sub or return empty array

Mostly for the sake of the OP and anyone else who thinks error return codes are a good idea.

The old school technique of returning a special value to indicate an error condition is kinda OK, but far better is to throw at the point the error condition is raised. That makes tracking down bugs related to detected errors much easier. The down side with ignoring errors is you may never notice the error condition and the code will quite happily complete - often very fast. That is of course an excellent outcome if you don't care that the result is bogus.

In cases where you know that something may fail but really don't care, wrap the called code in an eval and ignore the error. At least then you are explicitly ignoring the error rather than maybe just forgetting to test the result.

Premature optimization is the root of all job security
  • Comment on Re^2: Return array from sub or return empty array