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

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);

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 exploiting the Monastery: (5)
As of 2016-10-21 01:56 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (284 votes). Check out past polls.