This small program, quinify, produces a quining wrapper around any suitably simple perl program. The quined version writes its source to STDERR so that STDOUT remains available to the wrapped code. The program to wrap can be provided by a list of files on the command line,
$ quinify file1 file2 file3

through a pipe,
$ cat file.pl | quinify - | perl -w - 2>filequine.pl

or from the keyboard,
$ quinify >Quinequote
my $string = 'yields falsehood when preceded by its quotation';
print "'$string' $string.$/";
^D

Some of the usage is *nicentric.

'Suitably simple' means

  1. No use of the DATA filehandle.
  2. No verbosity over STDERR.
  3. No reliance on perl run options in the shebang line.
  4. Runs under strict and warnings.
If you notice other restrictions, please let me know. I'll add them to the list with credits.

Here's the code:

#!/usr/bin/perl -w use strict; { my @lines = map { chomp; $_ } <DATA>; # magical input permits interactive, piped, or # batch operation. push @lines, map { chomp; $_ } <>; { local $, = $/; print @lines,'__DATA__', reverse @lines; } } __DATA__ #!/usr/bin/perl -w use strict; { # This block prints the source to this program on stderr. # It quines there so that scripts which write to stdout # can operate unimpeded. Generated by quinify. my @ary= map { chomp; $_ } <DATA>; { local $,=$/; print STDERR reverse( @ary ), '__DATA__', @ary; } }
I use reverse to mung the source in data, mostly for visual effect. Any encryption-decryption scheme may be used, or none at all.

This may look familiar. I used a previous version, with a mildly obfuscated __DATA__ section, to quine There can be only one! in But There Are Two! .

After Compline,
Zaxo