First, why reinvent the wheel? logrotate

On to your code:

Assignments such as @ids = $id; are probably not doing what you expect, I suspect you want push instead: push @ids, $id;

For storing the values of the file, you might also want to look into a data structures such as "arrays of arrays" or "arrays of hashes" as described in perldsc.

For a simple way to list the contents of a directory, use glob: @files = glob("$path/*"); (there are several other ways but this one might be enough for your purposes). Also, if you do that, you won't need to concatenate the pathname and filename to get the absolute pathname, as you are currently doing.

To get the size of a file, it is enough to write -s $filename, i.e. in your case $flsize = -s $abspath; (see -X)

Lastly, the style of Perl you are writing in is a little outdated, you should begin your scrips with use warnings; use strict; to force yourself to stick to some less-error prone standards such as pre-declaring your variables.

Just one good resource of many is Modern Perl, available for free online.


In reply to Re: Log rotaion for the files which are existed in the absolute paths from the config files by Anonymous Monk
in thread Log rotaion for the files which are existed in the absolute paths from the config files by perladdict

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.