The key is understanding how mod_perl -- specifically, Apache::Registry -- handles a script. Basically, what it does is take each script and turn it into a subroutine. That one subroutine is compiled and can be executed again and again, without recompiling, which is one reason scripts run faster under Apache::Registry. But it makes certain scoping issues come into play, so you are exhorted more loudly than ever to use strict and declare variables with my, to ensure you don't have values lingering from previous invocations of your script, which is now a subroutine.

I can't tell you exactly why you're seeing differences (especially since you post no code! hint, hint =), but a lot might depend on how you're making calls to your subroutines. Make sure you always call them with

sub_name(ARG LIST)

and you shouldn't see any weirdnesses. If you make those changes and are still having problems, come back and ask again, with more specifics about the problem and a minimal code that produces the problem.

HTH.

Creates a sub bar that can be called from anywhere.

Philosophy can be made out of anything. Or less -- Jerry A. Fodor


In reply to Re: mod_perl and function declrations by arturo
in thread mod_perl and function declrations by one4k4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.