I've been running this in ActivePerl, but I think it should work fairly universally... Update: thanks to Hue-Bond for the heads-up on the warnings, here's version 2:
#!/usr/bin/perl sub {$_="/(Just).*( another).*( Perl).*( hacker,)/,print\$".((caller)[ +2]-1);eval}->(); sub {$_="/(Just).*( another).*( Perl).*( hacker,)/,print\$".((caller)[ +2]-1);eval}->(); sub {$_="/(Just).*( another).*( Perl).*( hacker,)/,print\$".((caller)[ +2]-1);eval}->(); sub {$_="/(Just).*( another).*( Perl).*( hacker,)/,print\$".((caller)[ +2]-1);eval}->();
~dewey

Replies are listed 'Best First'.
Re: Fourth time's the charm JAPH
by Hue-Bond (Priest) on Aug 22, 2006 at 09:49 UTC

    You can insert #line 2 just after the first line, to make sure the math goes as you expect (or use __LINE__). For instance, omitting the shebang line and doing perl foo.pl breaks the japh.

    To make it warnings clean, use (caller)[-1].

    --
    David Serrano

      The warning is fixed now, thanks. As to your first comment, it's true that the code is sensitive to changes, but that was my intention when I designed it to work this way. As long as the code is run exactly as I wrote it, it should work, eh? ~dewey
        As long as the code is run exactly as I wrote it, it should work, eh?

        No. Your code needs a line above it (such as a a shebang) to run exactly as you wrote it. But if it's your intention, that's fine then.

        --
        David Serrano