You don't need $confignr. Changing the for a bit will load $_ with each array element. (Note: for and foreach are the same.)

foreach (@config) { next unless /^(\b)\s+(\b)\s+(\b)/; my $file = $1; my $versions = $2; my $pidfile = $3;

the next unless /^(\b)\s+(\b)\s+(\b)/; line adds some error checking.

BTW, does that regex work?

The subroutine could be indented to highlight it better

Gzip => 'lib', Post => sub{ open(IN, $pidfile); $appid = <IN>; chomp $appid; kill("HUP", $appid); }, Dir => '/var/log/old', Flock => 'yes',
might look like:
File => $file, Count => $versions, Gzip => 'lib', Post => sub{ open(IN, $pidfile) or die "$pidfile: $!"; $appid = <IN>; chomp $appid; kill("HUP", $appid); }, Dir => '/var/log/old', Flock => 'yes',

You really should check the open for success. I'm uncertain why $appid is defined with our. Can you explain? Try testing $appid before killing it.

There should be no need to undef $log; as $log is lexically scoped to the foreach block.

instead of:
if (defined $log) { print "Looks ok..\n"; } else { die "An error accured processing config data\n"; } $log->rotate(); undef $log; }
how about:
defined $log or die "An error accured processing config data\n"; print "Looks ok..\n"; $log->rotate(); }



HTH,
Charles K. Clarkson



The vast majority of the Earth is underground. - R. Zubrin

In reply to Re: logrotate by CharlesClarkson
in thread logrotate by enaco

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.