GIF offers good possibilities for this sort of thing. Although Perl::Visualize doesn't seem to take advantage of this feature of the format, one interesting thing about GIF is that after the image data has finished, all subsequent contents of the file are ignored by renderers. Many image editors take advantage of this by allowing you to add a short textual "comment" to GIF images, but in fact, arbitrary binary data can be shoved there.

ZIP has even more potential for fun though. ZIP stores its "header" at the tail end of the file. This is a throwback to the world of floppy disks. Sometimes a ZIP file you were creating would span multiple disks, and the zip program would prompt you to insert disk after disk. Only after the final piece of compressed data had been written was the zip program actually able to build the header. Thus the header got written on the last disk (not the first), at the tail end of the file.

And so, you can actually add arbitrary data to the beginning of a ZIP file and it will be ignored when decompressing. (zip2exe tools take advantage of that.)

Assuming that foo.gif is a valid GIF file, and foo.zip is a valid ZIP file, then:

cat foo.gif foo.zip > foo.gif_zip

Will create a file that is both a valid GIF file and a valid ZIP file.

Similarly, if foo.pl is a Perl script that does not read from *DATA, then the following also works:

echo "__DATA__" > middle.txt && \ cat foo.pl middle.txt foo.zip > foo.pl_zip && \ rm middle.txt

Of course, it is also possible to write foo.pl so that it does read from *DATA and somehow uses the compressed data found there. Plenty of potential there.


In reply to Re^2: Candidate for a new "Evil Uses For Perl" section. by tobyink
in thread Candidate for a new "Evil Uses For Perl" section. by tobyink

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.