in reply to Scalar context with list and range operator
I have been trying a few variants and in addition to the "flip flop complication" I also got interference with print interpreting the parantheses as the function call operator.
my $x = ( 1 .. 5 ); # scalar context, flip flop print "$x <= 1\n"; # " <= 1\n" as $x is empty string print ( 1 .. 5 ), " <= 2\n"; # "12345" but no " <= 2\n", ( ) consumed + by print print +( 1 .. 5 ), " <= 3\n"; # "12345 <= 3\n" my $y = () = ( 1 .. 5 ); # enforces list context but then assigne +d to scalar print "$y <= 4\n"; # "5 <= 4\n"
|
|---|