Hello i am wondering if someone could please help me out I am having the following problem with the code below. First here is what the script does. I have about 200,000 plus files for which I need to go in a delete/remove the first four lines from. These are logs from a server, long story short for what we are doing wee need to delete the first four lines from the code. The problem that everytime I run the script below I get a OUT OF MEMORY error after the fourth or fifth log file(for the most part the files are under 10mb, but some are as large as 700mb...but I am only trying to remove the first four line from each log file). I am pretty new to perl and programming in general so I don't know if I am using perl to its best capabilities or if there is a better way to do what I am doing. Anyway any help would be appreciated. thanks for the help in advance.
#!/usr/bin/perl use File::Find; use Tie::File; my $DIRECTORY = $ARGV[0]; find(\&edits, $DIRECTORY); sub edits() { if ( -f and /^33dc01\..*outer.log$/ ) { foreach ( $File::Find::name ) { print "$File::Find::name\n"; tie my @file, 'Tie::File', $File::Find::name or die "Can't + tie $File::Find::name $!"; splice @file, 0, 4; untie @file; } } }

In reply to Removing lines from files by learningperl01

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.