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.
| [reply] |
EOF is just a character that has special meaning. Some programs (old, and maybe current, versions of DOS copy, for example) will stop processing a file when it runs into this character. Perl will not stop processing until the actual end of file. You still cannot read beyond the actual end of file, no matter what you try1. What problem are you trying to solve?
1 - Unless, as was previously mentioned, you create a device file that never stops generating information, ala /dev/zero under *nix2.
2 - Or your file system is broken - CFS anyone?
--MidLifeXis
| [reply] |