I have a piece of code this way:
use File::Tail;
$SIG{'INT'} = 'INT_handler';
sub INT_handler {
open(FILE,"/tmp/filename") || die "Cannot open file:$!";
$cur_filename=<FILE>;
close(FILE);
print("Don't Interrupt!\n");
chomp($cur_filename);
$file=File::Tail->new(name=>$cur_filename, maxinterval=>3, adjusta
+fter=>2,tail=>-1);
}
$cur_filename=$ARGV[0];
$file=File::Tail->new(name=>$cur_filename, maxinterval=>3, adjustafter
+=>2,tail=>-1);
while (defined($line=$file->read)) {
print $line;
}
Let me explain my intention. I have a constantly changing log and the log is rotated every hour(so a new log file is created every hour). What i intend to do is have a configuration file which has the current hour's log's filename and every hour I'll change the filename in this config file (externally from a diff prog ) and pass a INTsignal to the above code for it to pick up the newfile name.
But some how this doesnt work. The first time, File::Tail reads the file. But it doesnt read the new one when the INT_handler function handles the signal.
I'm also not sure if what i think is right...looking forward for suggestions.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.