in reply to Re: Is it possible to write a sub that understand default variables ?
in thread Is it possible to write a sub that understand default variables ?
I just tried "empty @a" against my solution. The _ prototype forces scalar context on the first argument:
/opt/perl/bin/perl5.10.0 -M5.10.0 -e 'sub display(_){say $_[0]};@a=(); +display(@a);push@a,"x";display(@a)'
Whether that is considered to be unintuitive or not depends on the user I guess
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Is it possible to write a sub that understand default variables ?
by ikegami (Patriarch) on Dec 24, 2007 at 18:36 UTC |