in reply to Using $! and passing errors
Exception handling is one of Perl's exceptional (ha!) weak points. You might want to read about Object-Oriented Exception Handling. It's a nice article, though it has some bugs in the code.
If you're going to keep it simple and return false, don't return 0 or undef! Instead, use a bare return:
unless ( $password_validated ) { # return 0; # <-- Usually bad return; } else { # do what must be done }
The problem with using return 0; or return undef; is that someone using your code might be assigning the results to an array. If so, checking for "truth" in the array will give a false positive because the array will then have one element whose value is zero or undef. Evaluating the array in a boolean context then evaluates as true instead of the expected false.
Cheers,
Ovid
New address of my CGI Course.
Silence is Evil
|
|---|