in reply to Re^6: Correct idiom for default parameters
in thread Correct idiom for default parameters
Arg! You're right. I tried it against my 5.10 version, because it was sitting there at the command prompt:
sub test{ my($p1,$p2,$p3) = map shift // $_,(1,2,3); print "p1:$p1; p2:$p2; p3:$p3"; };; [0] Perl> test();; p1:1; p2:2; p3:3 [0] Perl> test( 'a', 'b', 'c' );; p1:a; p2:b; p3:c [0] Perl> test( 'a', , 'c' );; p1:a; p2:c; p3:3 [0] Perl> test( 'a', undef, 'c' );; p1:a; p2:2; p3:c
|
|---|