Challenge : write a trivially useful program that compiles in perl and another language. No modules allowed. The example given in the CB was perl and SQL, but I'll be impressed for anything that works.

Replies are listed 'Best First'.
Re (tilly) 1: Challenge : use perl::polylingual
by tilly (Archbishop) on Jul 19, 2001 at 04:48 UTC
    What language is this finger exercise really in?
    #include <stdio.h> /* Simple example program to */ #define eval main() /* demo the preprocessor */ eval { printf("Hello world\n"); }
    Of course this is a simple joke. For truly impressive take a look at BooK's The Best Ever. It is a valid PostScript program and also a valid Perl program. Save it to a file and run with Perl or take a look at it with ghostscript. Both will work (though the output will be somewhat different). And what it does is not at all obvious.
Re: Challenge : use perl::polylingual
by bikeNomad (Priest) on Jul 19, 2001 at 02:45 UTC
    How about this valid Ruby or Perl program that is a simplified version of the Unix "yes" program:

    $\ = "\n"; print "y" while 1;

    If that isn't trivially useful, I don't know what is... what it's used for is to respond "y" to stupid prompts:

    yes | someProgramThatAsksALotOfYesNoQuestions

Re: Challenge : use perl::polylingual
by VSarkiss (Monsignor) on Jul 19, 2001 at 08:05 UTC

    Heh. I can't write one myself, but take a look at the Polyglot page for a list of for than a dozen polyglot programs (including one by BooK). The ultimate one, IMHO, is Polyglot, a ten-year-old program that compiles and runs in six or seven languages, depending on how you count. (I haven't tested it myself!)

    Edit: chipmunk 2001-07-19

Re: Challenge : use perl::polylingual
by japhy (Canon) on Jul 19, 2001 at 19:17 UTC
    This program runs the same under Python and Perl. (Aww, compiles?)
    die ' File "py.pl", line 2 \' File "py.pl", line 2 ^ SyntaxError: invalid token '

    _____________________________________________________
    Jeff japhy Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Re: Challenge : use perl::polylingual
by chipmunk (Parson) on Jul 19, 2001 at 20:42 UTC
    Here's a Perl / Oracle SQL snippet.

    Oracle has a special virtual table called DUAL from which you can select arbitrary data (useful with sequences, such as in SELECT customerID.NextVal FROM dual). This snippet probably won't work with other SQL flavors. :/

    select ('Just another SQL hacker'), '\' -- '; sub dual::from { print STDOUT "Just another Perl hacker!\n" } from dual
Re: Challenge : use perl::polylingual
by hding (Chaplain) on Jul 19, 2001 at 18:55 UTC

    I guess it depends what you mean by "trivially useful", but it's easy enough to write a kind of hello world that works in Perl and Common Lisp:

    (print "Hello, world!");

      or Perl and Basic:

      print "Hello, world!"

      -davisagli