Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: How to set timer in perl

by Bloodnok (Vicar)
on Jun 13, 2013 at 13:33 UTC ( #1038739=note: print w/replies, xml ) Need Help??


in reply to How to set timer in perl

In order to guide/help you without repeating steps you've already tried, whomsoever does reply would prefer to have a look see at what you've tried, by way of (skeletal) implementation, thus far i.e. in what way(s) did you try use alarm that didn't work.

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^2: How to set timer in perl
by Rahul Gupta (Sexton) on Jun 14, 2013 at 05:35 UTC
    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);
      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://1038739]
help
Chatterbox?
[Corion]: A good daypart!
Corion feels slightly bad for initiating a discussion yesterday and then running away. I guess I should write that up as a meditation or SoPW
[Corion]: Not the "running away" part but the question+ discussion about IO-less HTTP modules
[Corion]: (or how/where to patch AnyEvent::HTTP or LWP::UserAgent to take control of both the callstack and the data transfer)

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2016-12-08 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (137 votes). Check out past polls.