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
In reply to Re: sub returning undef
by qq
in thread sub returning undef
by Scarborough
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |