Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Slicing with Arrow-Operator possible in 5.12?

by LanX (Canon)
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

Comment on Slicing with Arrow-Operator possible in 5.12?
Download Code
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2015-10-07 16:22 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (191 votes), past polls