Dave's Brain

Browse - programming tips - perl delete array element

Date: 2010feb11
Created: 2009jul4
Language: perl

Q.  How do I delete an element from a perl array?

A.  To delete element $i from array @a do this:

	splice(@a, $i, 1);

This will decrement the number of elements in your array by 1.

There is also a "delete" command in perl but it does not do quite this.
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: