Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: A silly splicing question...

by marius (Hermit)
on Jan 19, 2001 at 05:11 UTC ( #52899=note: print w/ replies, xml ) Need Help??


in reply to A silly splicing question...

From the holy book of the camel:

splice ARRAY, OFFSET, LENGTH, LIST
splice ARRAY, OFFSET, LENGTH
splice ARRAY, OFFSET
This function removes the elements designated by OFFSET and
LENGTH from an array, and replaces them with the elements
of LIST, if any. The function returns the elements removed
from the array. The array grows or shrinks as necessary. If
LENGTH is omitted, the function removes everything from
OFFSET onward.
I'm not sure (not too familiar with splice) if you could set a length of 0, and do:
splice @a, 2, 0, 'foo'
Any takers care to deny or confirm this?

-marius

Update:redcloud, and a few others have either posted or CB'd me to let me know it works. woohoo! =]


Comment on Re: A silly splicing question...
Re: Re: A silly splicing question...
by redcloud (Parson) on Jan 19, 2001 at 05:14 UTC
    Confirmed. Setting LENGTH to 0 will insert LIST without removing any elements from ARRAY.
Re: Re: A silly splicing question...
by myocom (Deacon) on Jan 19, 2001 at 05:20 UTC

    Yepyep, that was the ticket. For some reason it hadn't occured to me to set length to zero (despite the docs blatantly pointing that out). myocom-- for stupidity. :-)

    Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://52899]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2014-07-28 23:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (210 votes), past polls