Perl Monk, Perl Meditation | |
PerlMonks |
Re: subroutine bewilderment: how to mimic builtinsby ikegami (Patriarch) |
on Feb 07, 2006 at 23:22 UTC ( [id://528666]=note: print w/replies, xml ) | Need Help?? |
To work on $_ by default, check the size of @_. For example,
To request a scalar argument, use prototypes. For example,
Finally, use wantarray to determine whether a list or a scalar (or nothing at all) should be returned. In Perl, your functions would be the following:
Update: Cleanup. Update: Fixed the typo japhy noticed in my prototypes.
In Section
Seekers of Perl Wisdom
|
|