|
this was very useful for me and thought i'd pass along the example.
use Getopt::Long;
my $filename=0;
GetOptions('file=s' => \$filename);
if( $filename ne "0") {
require File::Tail;
my $ref=tie *STDIN,"File::Tail", (name=>$filename);
}
while ( <STDIN> ) {
...
}
the same script can be used to read from STDIN:
cat logfile | script.pl
or watch the end of a file:
script.pl --file=logfile
|