Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Timeout not working while reading from socket.

by jrtaylor (Initiate)
on Jan 25, 2013 at 17:14 UTC ( #1015377=note: print w/ replies, xml ) Need Help??


in reply to Re: Timeout not working while reading from socket.
in thread Timeout not working while reading from socket.

I see what I did wrong..... THANKS. This seems to work.

while (my $line = <$sock>) { if ($line =~ m/^(ALARM: )/) { timeout $nb_secs => sub { while (2) { $buf .= $sock->getline(); $sock->flush(); } }; if ($@) { my $msg = MIME::Lite->new( ....... Type =>'TEXT', Data =>$buf , ); $msg->send(); print $file $buf; $line = ""; $buf = ""; } } print $file $line; #Print current line to open $file. } } sleep 10; # allow sometime to exit close $file;


Comment on Re^2: Timeout not working while reading from socket.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-09-15 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (146 votes), past polls