moof1138 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,
I made an AIM bot running on Mac OS X, using the Net::AIM module. The bot receives commands, which mostly involve reading and writing a database (with DBI), though sometimes a command will have it read a local file, or read and parse a web page. Everything works, but there is an oddball thing I can't figure out how to debug. If I use open() to open a file, or a pipe to a command, and then explicitly close() the handle, then suddenly I cannot send messages via AIM. Clients show the bot as on-line, it hears messages, and it logs that sends messages, but the messages go nowhere. If I use open() but never explicitly close() anything, then everything works (this is what I am doing now), but I get this bad feeling in the pit of my stomach, and the fact that something somewhere is wrong is bugging me. I have tried different filehandle names, thinking that this might be a namespace related thing, but that made no difference. I am still running the default version of Perl that came with Mac OS X. Does anyone have any pointers as to what I could do to try to debug this? I am using strict, and warnings, but that does not seem relevant for this oddball issue. I tried stepping through it in the debugger, but I could not really figure out what I was looking for.

Replies are listed 'Best First'.
Re: How to debug Net::AIM open() issue
by Aristotle (Chancellor) on Jun 23, 2002 at 10:59 UTC
    I don't know how much help the following idea really will be, since I'm totally befuzzled by the problem. But, have you tried using a lexical variable to hold the filehandle? open my $datafile, "<", $datafile_name;

    I'm not absolutely certain about this, but fairly sure that the file will be closed when this variable goes out of scope. Assuming you're reading the file inside a function, you wouldn't have to do anything to enforce that. Then you can see if that still leads to the same error.

    If nothing is wrong with the script, it might just be the C library your Perl was built with.. do you have access to any other computers of different flavour (Unix, Win32; well, VMS would work too *g*, as would some others) that have Perl installed? Try checking there for how the bot behaves, that might give you a hint of what's actually wrong.

    Makeshifts last the longest.

      Thanks Aristotle. I am reading the file in a function, so I will try using a lexical variable to hold the filehandle (did not know you could do that). At work I do not have access to any x86 systems, but I will try it with Linux PPC, and Solaris. I have decided to build a really small test program with fewer dependencies on modules other than Net::AIM, so I can test it at home since I have a K6III running Debian. That way I can see whether it is specific to something in my script, or something going on with the version of Perl & themodules I am using. Though if it is something with my script, I am lost.