Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Pass the value from perl script to html page

by TedPride (Priest)
on May 04, 2005 at 13:19 UTC ( [id://453937]=note: print w/replies, xml ) Need Help??


in reply to Pass the value from perl script to html page

Make a template file with distinctive tags to mark where data should be inserted. Load the file, replace the tags with variables. The following should explain what I mean, minus the loading of the template from a file.
use strict; use warnings; my ($text, %var); $var{VAR1} = 'hawg'; $var{VAR2} = 'mansion'; $var{VAR3} = 'flagpole'; read(DATA, $text, 8192); $text =~ s/<\?(\w+?)\?>/$var{$1}/g; print $text; __DATA__ Once upon a time there was a <?VAR1?> that lived in a <?VAR2?> on top of a <?VAR3?>.
Note that VAR1, VAR2, VAR3, etc. can be any variable names you want.

Replies are listed 'Best First'.
Re^2: Pass the value from perl script to html page
by Hero Zzyzzx (Curate) on May 04, 2005 at 16:20 UTC

    I realize you're just trying to be helpful, but I can't help but think code handouts like this harm a programmer learning perl in the medium term.

    What is a new programmer more likely to do:

    • Copy and paste this minimally functional templatting system that kinda works, or
    • Do the ultimately more productive thing and learn how to install and use modules from CPAN.

    Most newer programmers will probably choose the first, lesser productive route (but you know what they say about assumptions).

    Just saying. A nudge to use something like HTML::Template with some sample code would probably be more helpful over the long term.

    Here's something I whipped up to demonstrate some of what HTML::Template can do.

    -Any sufficiently advanced technology is
    indistinguishable from doubletalk.

    My Biz

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://453937]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-16 04:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found