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

There is a large number of J.A.P.H. programs floating around, but I am curious to know if they have ever been golf'd. Of course, most are elegant from a point of fantastic obfuscation, but not usually in terms of economy of characters. This, it seems, limits artistic expression.

Without the devious short-cut of calling the program "Just Another Perl Hacker" and then using:      print$0 As in, the name of the script is arbitrary, and as such, the code should be able to operate in a cut-and-paste capacity, just like most obfuscations.

The question is, is there anything more economical than:      print"Just Another Perl Hacker" Or, rather:      die"Just Another Perl Hacker\n" As far as I can tell, there is very little wiggle room.

Replies are listed 'Best First'.
Re: (Golf) JAPH?
by dailylemma (Scribe) on May 17, 2001 at 05:02 UTC
    This question has been asked before. The original work can be found here. They got it down to
    die`man $^Xfaq1`=~/"(j.*)"/
    as opposed to
    die"Just Another Perl Hacker\n"
    It's not exactly a general solution and the formatting is a little off, but I'm very impressed.
Re (tilly) 1: (Golf) JAPH?
by tilly (Archbishop) on May 17, 2001 at 04:52 UTC
    You always miss an obvious character:
    die'Just another Perl hacker '
Re: (Golf) JAPH?
by MeowChow (Vicar) on May 17, 2001 at 05:08 UTC
    Hmm... not very portable, but:
    perl -042e'print((`$^Xdoc -qj`)[1])'
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print
      ...and not really shorter :

      die"Just Another Perl Hacker\n"
      perl -042e'print((`$^Xdoc -qj`)[1])'

      BobiOne KenoBi ;)

Re: (Golf) JAPH?
by MeowChow (Vicar) on May 18, 2001 at 01:01 UTC
    The following code will print a JAPH, occasionally:
    print chr rand 127 for 1..25
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print
(kudra: being silly) Re: (Golf) JAPH?
by kudra (Vicar) on May 17, 2001 at 15:35 UTC
    The question is, is there anything more economical than: print"Just Another Perl Hacker"
    Sure. Same message, different words:
    die"JAPH\n"
    That's 11 keystrokes of code accompanied by over 1000 characters of hidden description (there's sure room for some golf with the description).
Re: (Golf) JAPH?
by dws (Chancellor) on May 17, 2001 at 04:54 UTC
    Going with the theory that you never really know where the lines are until you step over them, I submit die"$0\n" Of course, the file was named "Just Another Perl Hacker" ...

      I submit that the following is shorter:
      perl -pee
      Then start pressing the following keys: 'J', 'u', 's', 't' SPACE, 'A', 'n', 'o', 't', 'h', 'e', 'r', SPACE, 'P', 'e', 'r', 'l', SPACE, 'H', 'a', 'c', 'k', 'e', 'r', ENTER. Japhage magically occurs...
         MeowChow                                   
                     s aamecha.s a..a\u$&owag.print
      If you are going to go through this trouble, name the file "Just another Perl hacker,\n" and then reduce it to:
      die$0
        Not quite. You need the "\n" at the end of the die() argument to keep it from spitting out the filename (again) and line number.

Re: (Golf) JAPH?
by jmcnamara (Monsignor) on May 17, 2001 at 14:03 UTC

    Not shorter. perl -lpe '}$_="Just Another Perl Hacker";{' .

    John.
    --