Aside from your immediate problem there are a couple of style issues to consider that may help you in the future. First, always use strictures (use strict; use warnings;). Strictures catch a lot of silly typos and similar errors before they get a chance to waste a few hours trying to find subtle errors.

Don't use prototypes for subroutines. While there are a small number of situations where they are useful, generally they don't do what you think and often do what you don't expect. In the case of your sample code the prototype is actually ignored in any case because it hasn't been seen before it is used!

In the interests of showing you a little more Perl power consider:

sub edits { return unless -f and /^33dc01\..*outer.log$/; # Set up for in place edit local @ARGV = ($_); local $^I = '.bak'; print "$File::Find::name\n"; while (<>) { print if $. > 4; } }

which uses Perl's in place edit facility to rewrite the file having skipped the first four lines. Note that this will create backups of the original files with .bak appended to the file name.

The special variable $. provides the current line number for the file handle most recently accessed. See $^I, @ARGV, $. and $ARGV (which I didn't use, but may be of interest).


Perl is environmentally friendly - it saves trees

In reply to Re: Removing lines from files by GrandFather
in thread 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.