Do you know where your variables are? | |
PerlMonks |
Re: Log rotaion for the files which are existed in the absolute paths from the config filesby Anonymous Monk |
on Mar 27, 2014 at 21:11 UTC ( [id://1080006]=note: print w/replies, xml ) | Need Help?? |
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 Section
Seekers of Perl Wisdom
|
|