Your question is a bit vague, but if you're looking for the general purpose tool, it's splice. The others, shift and pop, can only perform a subset of what splice can do. Admittedly, this is a very useful subset that would be a hassle to use splice for all the time, but when you want general purpose you use general purpose.
In your case, it would be nice if you could collapse the user's selection into a set of ranges. If you don't want to do that, you could easily enough splice off one element at a time. The trick here is to iterate on the to-be-spliced indexes in descending order, otherwise you'll have to recalculate their new positions each time. Example:
my @array = (1 .. 1000);
my @toremove = (7,1,6,5,3);
for (sort { $b <=> $a } @toremove) {
splice @array, $_, 1;
}
# another way to to it:
for (reverse sort @toremove) { ... }
Update: the Other Way was flawed. It didn't do a numeric sort.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.