Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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]
[Corion]: Heh - I just realized, $work management just declared "no raises for anybody this year", and I'm not even angry about that. Even though that implicitly means "raises for the people with an automatic 5% raise in their contract", which the newly-merged ...
[Corion]: ... coworkers have. But I guess I've gone more mellow since I get to relax more, and such stuff doesn't make me as angry as it used to.
[Corion]: $boss will still get to listen to my interpretation :-D
[Eily]: hey, I'm just behind Larry in SioB \o/

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2018-01-22 11:05 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (233 votes). Check out past polls.