Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Slicing with Arrow-Operator possible in 5.12?

by LanX (Saint)
on Dec 22, 2008 at 17:06 UTC ( [id://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
      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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://732150]
Approved by Perlbotics
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-24 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found