LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi AFAIK it's not possible to produce a array or hashslice with an arrow dereference.
no warnings; $\="\n"; my $ar=[1..9]; print $ar->[1]; print $ar->[4..5]; # produces warning print @$ar[4..5]; __END__ 2 1 56
I remember I read somewhere that perl5porters received a patch to enable it and that'll be probably enabled in 5.12.

Couldn't find any infos on this, does anyone have a deeper insight or maybe a link?

Cheers Rolf

Replies are listed 'Best First'.
Re: Slicing with Arrow-Operator possible in 5.12?
by haoess (Curate) on Dec 22, 2008 at 19:31 UTC
      Thanks!

      Unfortunately there seem to be a compability conflict with hashes. For isntance $hr->{qw/this that/} already means $$hr{join $;,qw/this that/} !

      That's an old feature (perl4 ?) for multidimensional hashes $hash{"this","that"}!

      (for more see documentation for $; in perlop)

        You're looking for @{$hr}{qw/this that/}

        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?