Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Deleting lines from an array

by Abigail-II (Bishop)
on Jun 10, 2002 at 14:59 UTC ( #173175=note: print w/ replies, xml ) Need Help??


in reply to Deleting lines from an array
in thread Code explanation needed (was: What does this mean)

That's because a delete $array [$indx] only changes the size of the array if you are deleting from the end. If you really want it gone, you would use splice, but splicing away lots of individual elements from a large array is costly (as each splice in general take time linear in the size of the array).

You could change your print to:

defined ($_) && print FLE $_, $/ for @file;
unless you have undeleted, undefined elements in @file which you want to print. In that case, you could do something like:
foreach (0 .. $#file) { print FLE $file [$_], $/ if exists $file [$_] }

Abigail


Comment on Re: Deleting lines from an array
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2014-07-23 00:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (130 votes), past polls