Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Structure (timer) calling a method regularly in case of inactivity

by zentara (Cardinal)
on Jul 28, 2007 at 11:30 UTC ( [id://629286]=note: print w/replies, xml ) Need Help??


in reply to Structure (timer) calling a method regularly in case of inactivity

Glib ( the non-gui object class on which Gtk2 is built) will easily let you make a simple timer. See Roll your own Event-loop You can also subclass Glib but you may need to go to the maillist for help with that. See Subclass Glib
#!/usr/bin/perl use warnings; use strict; use Glib; my $main_loop = Glib::MainLoop->new; my $count = 1; my $timer = Glib::Timeout->add (1000, \&timer_callback, undef, 1 ); sub timer_callback{ $count++; print "$count\n"; return 1; # return 0 to stop timer } my $count1 = 1; my $timer1 = Glib::Timeout->add (100, \&timer1_callback, undef, 1 ); sub timer1_callback{ $count1++; print "\t$count1\n"; return 1; } ### filehandle watch open (FH, "+> test.log") or warn "$!\n"; Glib::IO->add_watch (fileno 'FH', ['in'], \&watch_callback, 'FH', 1 ); $main_loop->run; #################################################################### sub watch_callback { my ($fd, $condition, $fh) = @_; my @lines = <FH>; print @lines; #always return TRUE to continue the callback return 1; }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum
  • Comment on Re: Structure (timer) calling a method regularly in case of inactivity
  • Download Code

Replies are listed 'Best First'.
Re: Structure (timer) calling a method regularly in case of inactivity
by Iceman1884 (Initiate) on Jul 28, 2007 at 13:41 UTC
    Dear monks, Thank you very much for your help. As a new member, I am really impressed by the monk community's solidarity. I am trying to implement BrowserUk's thread method. Thanks again, Iceman
      Any chance you can simply increase the timeout at the Cisco device end or as part of your telnet connection? Many years ago I used Net::Telnet to visit a series of Cisco routers. I found Net::Telnet to be very capable and configurable. Plus, once connected to the Cisco router I could issue local commands to configure my session. I don't recall all the Cisco syntax but maybe there is some at the Cisco device end to keep your connection alive or a setting in Net::Telnet (or Net::Telnet::Cisco which I've not yet used). Just some ideas...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2025-03-18 04:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (56 votes). Check out past polls.