http://www.perlmonks.org?node_id=999670


in reply to Re^4: Question on design for FastCGI
in thread Question on design for FastCGI

Am I right to say I should not set variables like this before the FastCGI loop, but to get their values for each response within the loop?

yes , absolutely. Deciding whether a user is logged in (authentication), or allowed to view something (authorization), needs to happen from within the loop before you decide what kind of content (page) to return

How do I prevent bugs like this from happening?

proper scoping , read CGI to mod_perl Porting. mod_perl Coding guidelines, Lexical scoping like a fox, Variable Scoping in Perl: the basics

Replies are listed 'Best First'.
Re^6: Question on design for FastCGI
by Anonymous Monk on Oct 18, 2012 at 14:03 UTC

    Many thanks for your patience and enlightenment :)

    I had gone to the "CGI to mod_perl Porting, mod_perl Coding guidelines" before, which had given me some idea about what to expect. But until I actually encountered some of the issues caused by persistence, it was difficult to comprehend the ideas espoused. But I'm getting a better hang of it now than last week. At least now when something doesn't look right, I know where to look for the bug.

    Cheers and thanks again!