December 23, 2010
Perl return undef
Question
In Perl what is the difference between return and return undef
Answer
Using “return” alone returns an empty list in list context and undef in scalar context. On the other hand “return undef” always returns undef even in list context. Generally speaking it is not a good idea to return undef from a subroutine normally used in list context: