Yikes.
Don't do this.
If you want to protect a file from modification, use file permissions.
If you want to make the contents more difficult to read, encrypt the file.
If you want to store a secret value (eg, a password), and test to see if the user has supplied the correct value, hash the contents using something like Digest::SHA1, then test the user-supplied value by passing through the same hashing procedure.

Note that the first two options won't stop a determined user from doing what they want. They can change file permissions. They can inspect the file's content when your software decrypts it, plus your software would also have to store the decryption key somewhere, allowing decryption.

We'd need more information about what you're trying to do to be able to advise you further. As an aside, attempting to make other software crash is rude and arrogant at best


davis
It wasn't easy to juggle a pregnant wife and a troubled child, but somehow I managed to fit in eight hours of TV a day.

In reply to Re^2: Deleting EOF from a file by davis
in thread Deleting EOF from a file by nsyed

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.