in reply to Re: Re: Basic question
in thread Basic question

Of course it's possible that the scope of main and note is different. That's why I asked you to write a stand-alone piece of code, and not a piece of code where we have to fill in the blanks.

If you leave out the "...." in your code, it's impossible that $Report is empty, except for some bug in the implementation.

Abigail

Replies are listed 'Best First'.
Re^4: Basic question (mod_perl)
by tye (Sage) on Aug 20, 2003 at 15:35 UTC
    If you leave out the "...." in your code, it's impossible that $Report is empty

    Sorry, wrong. The part that is "left out" is mod_perl, which was clearly mentioned in the root node, and what it adds isn't where the "..."s in the shown code are.

    What it produces is close to:

    sub script { my $Report=""; sub note { my ($titre,$texte) = @_; my $Texte= '<H5>'.$titre.'</H5>­<P>'.$texte.'</P>'; $Report .=$Texte; } note($title,$text); print STDERR "*update.pl: end \n[\n$Report\n]\n"; }
    and each time the page is displayed:
    script()
    And that results in $Report being empty every time it is run except for the first. Certainly not "impossible".

                    - tye
      But in the original post, it says:
      My final print of $Report is sometimes empty

      Now, I can understand mod_perl resetting $Report each time the code is run. But resetting it right before the final print, after the subroutine call has added to it? In your code fragment, $Report isn't empty when it's being printed either.

      Abigail

        In your code fragment, $Report isn't empty when it's being printed either.

        Sorry, wrong again.

        sub script { my $Report=""; sub note { my ($titre,$texte) = @_; my $Texte= '<H5>'.$titre.'</H5>­­<P>'.$texte.'</P>'; $Report .=$Texte; } note($title,$text); print STDERR "*update.pl: end \n[\n$Report\n]\n"; } script(); script(); script();
        produces
        *update.pl: end [ <H5></H5>ĦĦ<P></P> ] *update.pl: end [ ] *update.pl: end [ ]
        and you can see that the final print of $Report is empty every time but the first, just like I said.

                        - tye