Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Slicing with Arrow-Operator possible in 5.12?

by LanX (Bishop)
on Dec 22, 2008 at 17:06 UTC ( #732150=perlquestion: print w/replies, xml ) Need Help??
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

      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?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://732150]
Approved by Perlbotics
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2018-06-18 06:31 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (108 votes). Check out past polls.