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

Re: Inotify2 + AnyEvent

by zentara (Archbishop)
on Oct 04, 2011 at 17:20 UTC ( #929603=note: print w/ replies, xml ) Need Help??


in reply to Inotify2 + AnyEvent

Just a guess from knowing how finicky calling subs by reference sometimes can be. Instead of

$watchObject = $inotify->watch ( "/var/log/snmptrapd.log", IN_MODIFY, \&processTrap);
try
$watchObject = $inotify->watch ( "/var/log/snmptrapd.log", IN_MODIFY, &processTrap() ); or "/var/log/snmptrapd.log", IN_MODIFY, processTrap() ); or "/var/log/snmptrapd.log", IN_MODIFY, sub{ processTrap() } );
anyways, experiment around with the way you call that sub. In the Ionotify2 docs, the examples show .... sub{ } notation, and I know Tk can get very fussy about the way subs are called. One tip, if you use &, include the ().

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh


Comment on Re: Inotify2 + AnyEvent
Select or Download Code
Re^2: Inotify2 + AnyEvent (now ne later)
by tye (Cardinal) on Oct 04, 2011 at 17:44 UTC

    I'd use \&processTrap. The sub { procesTrap() } should also work, but I don't recommend using that with Tk because I find that it can leak memory (and I don't know if Inotify2 avoids that problem). The other two things you suggested don't pass in a reference to code to be called later; they just call the code right then and then pass in whatever that code returns.

    - tye        

      Thank you gentlemen for replying. I tried the suggestions provided but they did not work. So I checked and saw that the script was working on the machine that had AnyEvent version 5.34 installed. I checked the version of AnyEvent on the machine that has the issue and saw that it was running version 7.02 of AnyEvent. So I downloaded the version 5.34 of AnyEvent and after installion, my application is running fine on the new machine. So I guess the version 7.02 introduced a bug. Thanks again for your replies.

Log In?
Username:
Password:

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

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

    April first is:







    Results (459 votes), past polls