It's not so much assuming you've got no idea what's in the file, as it is, *NOT* assuming that you will always know what's in it. With regard to security, the assumption is always that a file or other input could contain malicious data. There's no way to be certain of what the file contains, so you code defensively. Human error, malice, even a problem with the file system, could conceivably cause the input file to contain strings that would be devastating if executed. Check out an amusing take on this issue Can't Happen or /*NOTREACHED*/ or Real Programs Dump Core. It's somewhat dated, but still has many good points. Plus, it's fun.


In reply to Re^4: Reading from txt makes variables literal? by spiritway
in thread Reading from txt makes variables literal? by Anonymous Monk

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.