in reply to Re^3: Conditional initialization of my-variables
in thread Conditional initialization of my-variables
Gabor is mixing two cases in his article,
TIMTOWTDI, alas not very DRY
DB<30> x @_ 0 1 1 2 DB<31> x ($a,$b,$c,$d) = (@_, ("D1".."D4")[@_..3]) 0 1 1 2 2 'D3' 3 'D4' DB<32>
or
DB<32> @DEF= ("D1".."D4") DB<33> x ($a,$b,$c,$d) = (@_, @DEF[@_..$#DEF]) 0 1 1 2 2 'D3' 3 'D4' DB<34>
or
-->use v5.12.0; use warnings; use Data::Dump qw/pp dd/; sub test { my ($x, $y, $z) = ( @_, ("X","Y","Z")[@_..42] ); pp ($x, $y, $z); } test(1..$_) for 0..3
("X", "Y", "Z") (1, "Y", "Z") (1, 2, "Z") (1, 2, 3)
Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery
|
---|