in reply to Re: Re: Overriding Subroutines in Package
in thread Overriding Subroutines in Package

In Template, that's
[% world = "World" -%] <html> <body><h1>Hello $world</h1></body> </html>
And you don't have to expose Perl. Template is good. use Template!

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Re: Re: Overriding Subroutines in Package
by Tetramin (Sexton) on Oct 07, 2001 at 23:22 UTC

    For my script I am now using local to protect the system from being overridden under mod_perl. I don't really know if it's the right way, it's only the result of trial and failure.

    #!/usr/bin/perl use strict; use HSP; if ($ENV{MOD_PERL}) { my @keys = keys %HSP::; my $do = ''; foreach(@keys){ $do .= "local *HSP::$_ = *HSP::$_;"; } $do .= 'HSP::handle();'; eval $do; } else { HSP::handle(); }

    In fact, Toolkit, which you mentioned, has an option for variable interpolation, I just found that line that says it in the documentation. It's quite helpful when coding a template with an ASP capable editor. The code blocks appear in clickable boxes and the variables can be entered in the visible HTML. Only TT2 does use square brackets [% %] by default which should be changed to <% %> then.
    However just for my personal pleasure I would like to put perl within the brackets so I can have everything in one place. I have long enough put everything in the cgi-bin and started with #!/usr/bin/perl, I need a change!! Playing with this saves me from switching to php.