in reply to Re^2: Correct idiom for default parameters
in thread Correct idiom for default parameters
This is 5.8 accessible and might even be more palatable?
Updated per LanX's correction below.
sub test{ my( $p1, $p2, $p3) = map{ scalar @_ ? shift : $_ }( 1, 2, 3 ); print "p1:$p1; p2:$p2; p3:$p3"; };; test();; p1:1; p2:2; p3:3 test( 'a' );; p1:a; p2:2; p3:3 test( 'a', 'b', 'c' );; p1:a; p2:b; p3:c
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Correct idiom for default parameters
by LanX (Saint) on Apr 28, 2010 at 22:50 UTC | |
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 |