Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Interpolating $var in a $string

by eclark (Scribe)
on May 27, 2004 at 18:05 UTC ( #356996=note: print w/replies, xml ) Need Help??


in reply to Interpolating $var in a $string

This is fraught with danger, dont do this, use a template system like Text::Template, Template Toolkit, or something similar. But here's what you're trying to do.

#!/usr/bin/perl -w use strict; my $name = "Fred"; my @infile = <DATA>; my $tmpl = join '', @infile; # output print eval("qq{${tmpl}}"); __DATA__ This is my template. Here is my $name

Be warned, you can create a huge security hole by doing this.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2022-05-25 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?