in reply to why can't I shift a split?
shift requires an array (@NAME, @BLOCK, EXPR->@* and similar).
You want a list slice (( LIST )[ INDEXES ]).
Specifically,
( split( /,/, $_, 2 ) )[ 0 ]
If you are assigning the result to a scalar, you can also use
my ( $first ) = split( /,/, $_, 2 );
Using 2 for split's third operand isn't required; it's an optimization. There's no reason to continue splitting after the first split.
|
|---|