in reply to print $out doesn't always?

I find it unlikely it's a Perl problem. Where is STDOUT going to? Is it redirected to a resource that has problems? (pipe, file, socket?) What happens if you change the print to a warn? Did you run it from the command line, or do you only have problems with it when running from Apache?

Abigail

Replies are listed 'Best First'.
Re: Re: print $out doesn't always?
by pumpsoft (Initiate) on Jun 11, 2002 at 18:54 UTC
    The way I understand it, here's the way it's supposed to work...

    The slashd script is running as a daemon, it calls various housekeeping scripts periodically. The freshenup.pl script gets called by slashd. freshenup.pl contains a call to prog2file() which is used to execute a script and direct the output to a file. prog2file() is executing the script with this line:
    $data = `$exec`;
    thus capturing the output of the command in a variable which it prints to a file later. The value of $exec at runtime is valid and intended to run article.pl with appropriate arguments.

    article.pl runs, and in turn results in a call to index.pl to update the index. index.pl calls slashDisplay() several times and receives the output as a returned value. index.pl then calls slashDisplay() again to print the output instead of return the output. It is this line that is hanging.

    So I think the calling order is:

    slashd
    freshenup.pl
    prog2file()
    article.pl()
    index.pl()

    I can run index.pl from the command line using the same arguments with no problem. As far as I see, STDOUT isn't being redirected to any file or socket, etc. I think it's supposed to get to the parent script, and so on up the tree. It's the prog2file() sub that uses the backtick form of the system() command to capture the output of all the children into a scalar and print it to a file.

    I'm not fluent enough in this yet to know how to accurately trace the STDOUT path here. I'm told perhaps the parent's pipe has stalled, but I don't know how to investigate that. I didn't write this code, of course, and it's my significant first exposure to perl programming. (slashcode probably isn't the best thing to cut my perl teeth on, but that's the way it's working out!)