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

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

Replies are listed 'Best First'.
Re^2: Inotify2 + AnyEvent (now ne later)
by tye (Sage) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://929603]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2017-10-20 05:42 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (258 votes). Check out past polls.