http://www.perlmonks.org?node_id=498060


in reply to [OT] Perl Code Embedded in an Image

Without having known about your post, I wondered on the same thing a few months later.

I wanted an image that runs as a perl script without the -x switch or any other switches.

First, I've decided that this was impossible to do with a PNG image, because perl chokes right away on its header.

Then, I was looking at GIF, but I've found the specs too complicated, so I took it away.

I've however produced a BMP (windows bitmap) that doubles as a JAPH. BMP is now displayed in most browsers, however it's not allowed to upload one as a monk image (maybe because when this was decided, Netscape 4 which doesn't have BMP support, was still common back then). Thus, I can only show this image off-site: japh.bmp.

To try the perl part, download it and run with perl japh.bmp.

(The japh this one has is a trivial one, but I can change it to any perl code of course.)

Replies are listed 'Best First'.
Re^2: [OT] Perl Code Embedded in an Image
by ambrus (Abbot) on Feb 16, 2012 at 11:48 UTC

    I want to upload a copy of that file here in case you can't reach the external server. However, I don't want to just include it in code tags because that could break it (by eg. mangling newline characters).

    Thus, here's a perl script that you should run to reproduce the script: redirect its output to a file, say japh.bmp, then run the resulting file with perl like perl japh.bmp and/or view it with some image viewer program.