in reply to Re: The syntaxes @a->[...] and %h->{...} have now been deprecated
in thread The syntaxes @a->[...] and %h->{...} have now been deprecated

The 'bad' syntax works but gets a single element 'slice' and is in array (not scalar) context which may behave in slightly unexpected ways for which I can not generate a one line example.

I don't think this really has anything to do with slices. Nor is it a matter of context. It's just a syntactical freak of Perl nature... Frankenstyle.

Some examples:

perl -le '@foo = qw( f o o ); print @foo->[0]' # Frankenstyle perl -le '@foo = qw( f o o ); print @foo->[0,1,2]' # Frankenslice? perl -le '@foo = qw( f o o ); print @foo[0,1,2]' # Working slice. #### And a demo of context... perl -wle 'sub c {print wantarray ? "list" : "scalar" } my @foo; @foo += c;' perl -wle 'sub c {print wantarray ? "list" : "scalar" } my @foo; $foo[ +0] = c;' perl -wle 'sub c {print wantarray ? "list" : "scalar" } my @foo; @foo[ +0,1] = c;' # And Frankenstyle.... perl -wle 'sub c {print wantarray ? "list" : "scalar" } my @foo; @foo- +>[0] = c;'

-sauoq
"My two cents aren't worth a dime.";
  • Comment on Re: Re: The syntaxes @a->[...] and %h->{...} have now been deprecated
  • Download Code