in reply to Log rotaion for the files which are existed in the absolute paths from the config files

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.

  • Comment on Re: Log rotaion for the files which are existed in the absolute paths from the config files
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Log rotaion for the files which are existed in the absolute paths from the config files
by Anonymous Monk on Mar 27, 2014 at 21:21 UTC

    Minor correction: Since your $path already contains wildcard characters, it's enough to do @files = glob($path); (assuming the wildcards used in the config file are compatible with glob)