Here's an application of a problem-solving strategy I've found to be occasionally helpful

  1. Consult perldoc perldiag if you don't understand the error message
  2. Work out why you're getting the error message (if it isn't obvious) from the information thus gleaned.
  3. Follow up on any suggestions you can find in the docs.

Interesting how this question came up right after one4k4's concerning a similar issue; long story short, your whole script is a subroutine when you run it under Apache::Registry. 'Course, you're getting it because you have a nested sub the way you've coded it anyhow. But back to the strategy outlined above =>

From perldoc perldiag the solution to the "won't stay shared" issue is:

This problem can usually be solved by making the inner
              subroutine anonymous, using the sub {} syntax.

Another approach would be to move the read_size subroutine's declaration outside of the block.

These are purely structural solutions; I'm not even sure you need to be doing what you're trying to do here (read is built to handle the issue of when you try to read a larger chunk than what's left in the file).

HTH

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


In reply to Re: mod_perl: variable $end will not stay shared (nested subroutines problem) by arturo
in thread mod_perl: variable $end will not stay shared (nested subroutines problem) by princepawn

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.