Uh...

Just a note that this can be a little dangerous. In the worst case, the eval will mess up. But if someone just wants to mess with you, they can do a very nice job of it. Observe:

my $line = 'TEXT=};print `ps`;print "Your machine is h4x0r3d!!$/";qq{H +ello\nWorld!\n'; .. OUTPUT: PID TT STAT TIME COMMAND 5808 p0 S 0:00.02 _su (csh) 5816 p0 S+ 0:00.01 perl mylittleprogram.pl 5817 p0 R+ 0:00.00 ps 149 v0 IWs+ 0:00.00 /usr/libexec/getty Pc ttyv0 Your machine is h4x0red!! Hello World #

I'm just showing that this can be a little dangerous but if you're the only one who is writing to the config file, you'll need to make certain you never use } or you'll most likely get $interpolated = undef. Of course, a prankster could put some code in the config file as I just showed and have it do a lot of nifty things and you still get the output you expected. So it could be some time before you'd realize anything is wrong at all. Of course, what are the chances of that? ;-)

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1


In reply to Re: Re: print real newlines in place of literal ones by antirice
in thread print real newlines in place of literal ones by blueAdept

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.