in reply to Re^3: Correct idiom for default parameters
in thread Correct idiom for default parameters
passing undef in between will break your idiom.
IMHO better check scalar @_ or care explicitly about passing undef !
sub defaults { my( $p1, $p2, $p3) = map{ defined $_[0] ? shift : $_ }( 1, 2, 3 ); + print "p1:$p1; p2:$p2; p3:$p3\n"; }; defaults(undef, 0, 0);
Cheers Rolf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Correct idiom for default parameters
by BrowserUk (Patriarch) on Apr 28, 2010 at 22:59 UTC | |
by LanX (Saint) on Apr 28, 2010 at 23:05 UTC | |
by BrowserUk (Patriarch) on Apr 28, 2010 at 23:24 UTC |