Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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);


Comment on Re^2: How to set timer in perl
Download Code
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2015-07-02 16:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (44 votes), past polls