Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Returning Variables from files

by dpuu (Chaplain)
on Jul 21, 2002 at 20:49 UTC ( [id://183869]=note: print w/replies, xml ) Need Help??


in reply to Returning Variables from files

Imagine you wanted to write the output as a perl print statement: you could write:
my $name = "Dave"; my $user = "dpuu"; print <<HERE; Hello, my name is $name and my user name is $user HERE
This will do variable interpolation on a set of lines.

If you want to separate the script and the flat-file, you can create a print-statement on the fly, using eval:

my $name="Dave"; my $user="dpuu"; my $text_file="User.htm"; my $text=`cat $text_file`; eval "print <<HERE;\n$text\nHERE";
You want to be careful when putting this in a production environment: executing data files as code could introduce some security holes (or just very strange bugs). This script won't work with perl's -T option --Dave.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (None)
    As of 2024-04-25 00:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found