List Info

Thread: Re: Use File::Tail on two (2) files at the same time




Re: Use File::Tail on two (2) files at the same time
user name
2007-01-24 08:57:49
--- In perl-beginner@yahoogroups.com, Paul Archer ...> wrote: > > 12:55pm, joel_carnat wrote: > > > Hi, > > > > I have grabbed and modify a Perl script that opens a log file and use > > File::Tail and regexp to fill a DB according to matching wildcards > > that appear in that logfile. I would like to modify this script so > > that it checks two log files at the same time. > > > > Here's my current script: > > $log_file = "/var/log/mail.log" > > my $logref=tie(*LOG,"File::Tail",(name=>$log_file,debug=>$debug)); > > while () { > > if (/postfix/(smtp|virtual)[.*status=sent/) { > > // do things > > } elsif (/postfix/smtp[.*status=deferred/) { > > // do other things > > }; > > }; > > > > What I would like is the script to look at /var/log/mail.log > > and /var/log/messages.log (for example) at the same time. > > > > I can't find how to code this. > > Do I need two $logref, can I use things like "while ( and > > ) {" things, ... > > > > I believe the two main approaches here would be to use forks or threads to > split the tasks out (ie each forked copy or each thread handles a different > file), or to use the four-arg version of select with a short timeout value > to poll each file in turn. > > Paul > thank you, I'll have a look at threads. Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/perl-beginner/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/perl-beginner/join (Yahoo! ID required) <*> To change settings via email: mailto:perl-beginner-digest@yahoogroups.com mailto:perl-beginner-fullfeatured@yahoogroups.com <*> To unsubscribe from this group, send an email to: perl-beginner-unsubscribe@yahoogroups.com <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )