Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Module for Perl's "here-is" text formatting

by TedPride (Priest)
on May 24, 2006 at 17:04 UTC ( [id://551412]=note: print w/replies, xml ) Need Help??


in reply to Module for Perl's "here-is" text formatting

What you're probably looking for is a way to load data into your template from variables. But you're going about this the wrong way. Use a hash to store the data, and regex to substitute:
use strict; use warnings; my %vars = ( var1 => 'MyValue', ); my $here_is = <<SOME_TEXT; I want to print something with a value %var1% and some other text load etc etc SOME_TEXT $here_is =~ s/%(\w+?)%/$vars{$1}/g; print $here_is;
You may also want to look at loading the template from a file or __DATA__, so you're not forced to allow the extra line break that <<TAG makes mandatory.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-23 12:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found