Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: How to set timer in perl

by Rahul Gupta (Sexton)
on Jun 14, 2013 at 05:35 UTC ( #1038889=note: print w/replies, xml ) Need Help??


in reply to Re: How to set timer in perl
in thread How to set timer in perl

hi,

Here is the code which i have tried.

#!/usr/bin/perl -w use strict; my $FH; local $SIG{ALRM} = sub { die "Timeout no data received\n"; }; open ($FH, '<', "file1") or die "cant open file to read file$!.\n"; alarm 5; while (<$FH>){ if ($_ =~ m/any string/i){ print "$_\n"; alarm 0; } } close ($FH);

Replies are listed 'Best First'.
Re^3: How to set timer in perl
by Anonymous Monk on Jun 14, 2013 at 07:18 UTC
    I'd venture to say that you're hitting EOF and exiting the loop before the five seconds have passed. Perhaps you want File::Tail?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038889]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2017-10-23 12:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (279 votes). Check out past polls.

    Notices?