in reply to Re: Browser Timeout
in thread Browser Timeout

I'm curious because I've never used them, but what's the added advantage or utility of an NPH script over a non-NPH script. To bypass output buffer and avoid browser timeouts, I usually just set $&#124 and an alarm:

{ local $| = 1; local $SIG{ALRM} = sub { print `/usr/bin/fortune`; alarm ALARM_TIME; + }; alarm 1; ... process that (might) take a very long time ... alarm 0; }

Would using NPH be better?

update Thanks, merlyn.

Thanks, ERic

Replies are listed 'Best First'.
Re: NPH scripts? (was Re: Browser Timeout)
by merlyn (Sage) on Feb 23, 2001 at 00:00 UTC
    This works under modern Apache, but under older Apache versions, the script also had to be named nph-something to turn off the buffering. Consider the name as a signal that Apache should do its own $| = 1 equivalent.

    The other things that older Apache required was that these "NPH" scripts provide the first HTTP status line as well, since Apache essentially stepped out of the way entirely. I think this is still true for scripts named like this as a backward compatiblity.

    -- Randal L. Schwartz, Perl hacker

Re: NPH scripts? (was Re: Browser Timeout)
by shambright (Beadle) on May 12, 2001 at 21:58 UTC
    I have the same question.... I have several scripts that take longer than my browser has patience. Where exactly do I PUT the ' $|=1; ' in order to make sure that I don't get timed out?