in reply to scalar slice assignment doubt
If you want the last element of a list, you can use a list slice.
my $last = ( LIST )[-1];
The parens are required.
For example,
my $last = ( 'a', 'b', 'c' )[-1]; my $last = ( 'a' .. 'c' )[-1]; my $last = ( split(/,/, "a,b,c") )[-1];
Note there's no such thing as a scalar slice. You can't slice a scalar into its components.
|
|---|