Posted on 2009-05-05 13:33:00-07 by steventardy
useful example - override STDIN
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
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.