in reply to Return Question in Subroutine

When you do your return, you should not return an empty string. It works as long as you return it as just a string which gets check but lets suppose this,
my @result = $object->cleanup; if (@result) { print "Got some results back '@result'\n" } __END__ # # You will always get this back if you do return ''; # Got some results back ''
You always return undef for nothing and your code will work in the way you think and it is easier to read. Just replace that last bit with this.
return $_[0]; } return;

Replies are listed 'Best First'.
Re^2: Return Question in Subroutine
by Anonymous Monk on Apr 28, 2006 at 13:44 UTC
    That is a very good point "you should not return an empty string", but isn't it this way of not having the log file printing the initialized value error?