Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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


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
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038889]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2015-10-06 22:46 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (163 votes), past polls