Hi Chris,
Where you have the statement:
$template2 = $template ;
Essentially what you are doing here is creating a variable $template2 that
points to the same object as referenced by $template. An object in perl is
a blessed reference and so you have just made a copy of a reference. So
$template2 and $template point to the same object.
If you wish to make a true copy of the object, you will need to look at
things like Data::Dumper or better still the Storage module which has freeze
and thaw subroutines. Hopefully this will achieve what you want.
All the best.
Regards,
Damien.
On 19/12/08 7:32 AM, "cfaust-dougot" <cfa...@doyougot.com> wrote:
> Folks,
>
> I'm trying to create 2 different vars from the same template object and it
> appears once I do so that whatever I set in one gets set in the other. What am
> I missing? Is it because I'm creating a reference? (I didn't think that was
> the case).
>
> Here is an example of what I mean
>
> my $template_object = qq|<TMPL_IF NAME="Var1"> Var 1 is set</TMPL_IF><TMPL_IF
> NAME="Var2"> Var 2 is set</TMPL_IF>|;
>
> my $template = HTML::Template->new(scalarref => \$template_object);
>
> $template->param(Var1 => 1);
>
> my $template2 = $template;
>
> $template2->param(Var2 => 1);
>
> print $template->output();
>
> The output I get is: "Var 1 is set Var 2 is set" even though I set "Var2" only
> in $template2 only
>
>
> TIA!
> -Chris
>
>
> ------------------------------------------------------------------------------
> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
> The future of the web can't happen without you. Join us at MIX09 to help
> pave the way to the Next Web now. Learn more and register at
> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
>
> _______________________________________________
> Html-template-users mailing list
> Html-template-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/html-template-users
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Html-template-users mailing list
Html-template-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/html-template-users