You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "goEbusiness.com Mail Lists" <ma...@goebusiness.com> on 2000/08/15 02:01:07 UTC

Text::Template, PACKAGES, ModPerl

Ok, here's the scenarious.

Runnign Text::Template with a PACKAGE.  Let's just call it M.

So, for example, I have a script

$M::fill_me_in and Text::Template will fill that variable in.

Anyway, I know that those are global variables, so when I enable mod_perl, they retain the previous values.

Is there a quick easy way to reset all of those variables for each time the script is run?  I'm assuming no.  I did make a function that ran through the package, like so:

	my ($key,$value) ;

        foreach $key (sort keys %main::M::) {
                my $value = $main::M::{$key} ; 
                $main::M::{$key} = "" ; # reset to blank 
        }

and placing that at the bottom of the mod perl enabled script...but it doesn't work.

I tried "reset 'M'" and that also doesn't work.

Any thoughts on this?  The short term solution I have come up with is that in every sub/package/whatever I reset those variables to blank each time the subroutine that would fill those in is called.  Is that the best way to do it?  I would think the way I mentioned above would work, but maybe I just have to call that from each sub routinue.

Thanks,
Bill
maillist@goebusiness.com


Re: Text::Template, PACKAGES, ModPerl

Posted by John Hurst <jh...@interpacket.net>.
"goEbusiness.com Mail Lists" wrote:
> 
> Ok, here's the scenarious.
<snip>
> Is there a quick easy way to reset all of those variables for
> each time the script is run?  I'm assuming no.  I did make a
> function that ran through the package, like so:
<snip>

Re: Text::Template, PACKAGES, ModPerl

Posted by ___cliff rayman___ <cl...@genwax.com>.
"goEbusiness.com Mail Lists" wrote:

> Ok, here's the scenarious.
>
> Runnign Text::Template with a PACKAGE.  Let's just call it M.
>
> So, for example, I have a script
>
> $M::fill_me_in and Text::Template will fill that variable in.
>
> Anyway, I know that those are global variables, so when I enable mod_perl, they retain the previous values.
>
> Is there a quick easy way to reset all of those variables for each time the script is run?  I'm assuming no.  I did make a function that ran through the package, like so:
>
>         my ($key,$value) ;
>
>         foreach $key (sort keys %main::M::) {

foreach $key (keys %::M::){ #the stash is not in any package

>
>                 my $value = $main::M::{$key} ;

the line above is useless.  you were probably using for debugging?

>
>                 $main::M::{$key} = "" ; # reset to blank

${$::M::{$key}}=undef;

>
>         }
>
> and placing that at the bottom of the mod perl enabled script...but it doesn't work.

it will work now.
you may want to rethink your code before going throught this for every call.
also, there might be a better way to reset globals, but the changes i provided should correct the script above.

>
>
> I tried "reset 'M'" and that also doesn't work.
>
> Any thoughts on this?  The short term solution I have come up with is that in every sub/package/whatever I reset those variables to blank each time the subroutine that would fill those in is called.  Is that the best way to do it?  I would think the way I mentioned above would work, but maybe I just have to call that from each sub routinue.
>
> Thanks,
> Bill
> maillist@goebusiness.com

--
___cliff rayman___cliff@genwax.com___http://www.genwax.com/