Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Last index use in array slice

by LanX (Chancellor)
on Dec 03, 2012 at 12:41 UTC ( #1006871=note: print w/replies, xml ) Need Help??

in reply to Last index use in array slice


(UPDATED code for clarification)

DB<123> $str =join '', a..h => "abcdefgh" DB<124> ( undef, undef, undef, undef , @rest) = split //, $str => ("a", "b", "c", "d", "e", "f", "g", "h") DB<125> @rest => ("e", "f", "g", "h")

with arbitrary index, we'll need a dummy array to swallow ignored entries:

DB<126> $index=4 => 4 DB<127> ( @ignore[1..$index] , @rest) = split //, $str => ("a", "b", "c", "d", "e", "f", "g", "h") DB<128> @rest => ("e", "f", "g", "h")

cause unfortunately this doesn't work:

DB<129> ( ( (undef) x $index ) , @rest) = split //, $str Can't modify repeat (x) in list assignment at (eval 65)[multi_perl5db. +pl:638] line 2, at EOF

Cheers Rolf

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006871]
[ambrus]: Corion: actually, schmorp has complained about how you used that syntax in the draft for AnyEvent::Impl:: Prima. I don't think he screamed, but whatever.
[ambrus]: Yes, I know you fixed that since.

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2017-02-27 14:52 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (388 votes). Check out past polls.