in reply to Re: Deleting Oldest Logfiles
in thread Deleting Oldest Logfiles

Hi Monks,

Firstly thanks a lot for all your help, and shame on me for that error on the first chomp snippet. Moritz thanks to you especially cause the code you sent seems very elegant and functional to solve my problem. I decided to put it in my script, anyway since i'm trying to learn Perl... There are 2 obscure points in your code which i still didn't grasp completely and i'd be glad if you or somebody else in this monastery could explain them to me.

1. The -1 and the 2 within square brackets inside the partition_usage sub. What is their exact purpose?
2. If i had to glob for zipped logfiles within subdirectories how could i do it?

Thx Again,

Francesco

Replies are listed 'Best First'.
Re^3: Deleting Oldest Logfiles
by moritz (Cardinal) on Oct 23, 2008 at 11:49 UTC
    1. The -1 and the 2 within square brackets inside the partition_usage sub. What is their exact purpose?

    The construct before these square brackets return lists. [2] picks the third item of that list (remember, indexes are zero-based) (here: the third whitespace delimited field of the input), and [-1] returns the last list item.

    2. If i had to glob for zipped logfiles within subdirectories how could i do it?

    If you have fixed depth, say 2, you could write */*/*.log.gz. If not you'd have to use File::Find (or File::Find::Rule, which beginners seem to like better).

      Hi Moritz,
      Since i got fixed depth i adopted the asterisk solution, tested the code and everythings seems to work fine!! Thx again!

      F