Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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
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
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? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2014-09-20 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (157 votes), past polls