With regard to the size of your file you are parsing memory management vs speed will be a consideration.

You mentioned matching rows who's first element is found in an array. To step through your whole array for each row is a big expense. If your match array is 20 elements and you have 1,000,000 lines that means you have to loop 1,000,000 x 20 times. That's expensive!! For your match array you may want to make a hash instead and then check for the existence of the hash key

%hash = {'match1'=> 1; 'match2' => 1; } foreach $row (@file) { if (exists hash{$$row[0]}) { ## do something } }
Speed wise: splicing an array can be expensive, as NetWallah suggests, so try "undef". This though can be expensive memory wise for large arrays. You have to consider your uses and what is best.

Also speed wise its faster to read a file into memory and then do what you want on it, rather than process as you read from the file. Although a 3Gb is a LOT of file and you will be hardup to read all that into memory.
open (FILE, "<$file") or die $!; @file = <FILE>; foreach $row (@file) { ## do something with $row }
Just some things to think about.

Dean

Programming these days takes more than a lone avenger with a compiler. - sam

In reply to Re: Deleting internal array elements by crabbdean
in thread Deleting internal array elements by Itatsumaki

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.