in reply to sub returning undef

I have a sub which if all goes well returns an array but if a error is encounted returns undef. I belived this to be good style and know that many built in functions do this.

Abigail-II provided the answer, but its getting a bit obscured. Its not good style to return undef because if its assigned to an array you get a one element list. Its better style to just return. Because that is shorthand for:

wantarray ? () : undef;

Which is what you almost always want

qq

Replies are listed 'Best First'.
Re: Re: sub returning undef
by adamk (Chaplain) on May 26, 2004 at 06:48 UTC
    Unless of course the method can legally return a null list, in which case it isn't :)