H.Merijn Brand wrote: >> sub NAME >> { >> ... lots of code ... >> >> undef; >> } >> > > What if the function can return a list or a scalar? "return" handles > that automatically, undef does not; > Hehe - good question. My answer is that it tends not to happen for my style of programming. That is, a function that returns a list would take the form: sub NAME { my @results; ... do whatever to @results ... @results; } Now, I do recall it happening once in the past where I found the need to return from @results from inside a conditional - and I think I decided on "return ();" as I found "return;" to not communicate "return an empty list" as explicitly as I wanted. It was an imperfect situation. :-( > BTW I agree with both worlds. In some cases it should suffice to use > the last value, in some cases one should use return for clarity > Agree. I was playing devil's advocate - not intending to say "never ever use return!". I only challenged the claim that one should "always use return!". :-) It came across as dogma like "never use goto!". :-) Cheers, mark -- Mark Mielke <mark@mielke.cc>Thread Previous | Thread Next