Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Returning Variables from files

by dpuu (Chaplain)
on Jul 21, 2002 at 20:49 UTC ( #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? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2022-01-26 20:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (70 votes). Check out past polls.

    Notices?