Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: An efficient way to remove an element from an array

by linuxkid (Sexton)
on Aug 06, 2012 at 15:50 UTC ( [id://985757]=note: print w/replies, xml ) Need Help??


in reply to An efficient way to remove an element from an array

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: An efficient way to remove an element from an array
by davido (Cardinal) on Aug 16, 2012 at 17:52 UTC

    Let me try to explain why this response might have attracted so many downvotes, and more importantly, why it's not good advice.

    Actually, the documentation does a better job than I could do:

    delete() may also be used on arrays and array slices, but its behavior is less straightforward. Although exists() will return false for deleted entries, deleting array elements never changes indices of existing values; use shift() or splice() for that. However, if all deleted elements fall at the end of an array, the array's size shrinks to the position of the highest element that still tests true for exists(), or to 0 if none do.

    WARNING: Calling delete on array values is deprecated and likely to be removed in a future version of Perl.

    (Emphasis added.)


    Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-24 06:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found