Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How do I completely remove an element from an array?

by vroom (His Eminence)
on Jan 09, 2000 at 10:16 UTC ( [id://1908]=note: print w/replies, xml ) Need Help??


in reply to How do I completely remove an element from an array?

splice was designed to handle this.
splice @array, $indextoremove, 1;

splice can be called in any of the following forms:

splice ARRAY, OFFSET, LENGTH #removes anything from the OFFSET index through the index OFFSET+LENGT +H-1 splice ARRAY, OFFSET, LENGTH, LIST #same as the previous but replaces elements removed with those in LIST splice ARRAY, OFFSET #removes anything from the OFFSET index on

In any of these cases, splice returns the elements it removed.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2025-07-12 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.