A first (published) attempt at this sort of thing. Really an excessive amount of code. But it's probably not really well obfuscated.

#!/usr/bin/perl -w package DB;our $sub='main::er';sub BEGIN{$^P=1 unless$sub; $^P or $_="Not just another perl hack"}sub sub(hack){print $sub =~ /([^:]+)$/, $", or &$sub} *hacker = \&sub; package main;sub er {print ",\n"}sub just {for(split' '=>`perldoc` ){print $1 if /(\w{4})\d\w/;}}sub hack {print "hacker"}sub another { seek DATA, 0, 0;print +(/(\w{6})\W/)?$1:'' while <DATA>;DB::hacker();}sub perl { print }$_ and print "$_\n" ;foreach (qw{just another perl hack}) {$_->();}print "\n";

Replies are listed 'Best First'.
Re: an attempt at misdirection
by tachyon (Chancellor) on May 27, 2001 at 15:38 UTC

    She broke, freeze my 'puter in infinite loop. No action. Need Ctrl+C.

    Win32 box, perl 5.6.0

    tachyon

Re: an attempt at misdirection
by srawls (Friar) on May 27, 2001 at 18:08 UTC
    Doesn't work for me, I'm guessing this is just a typo or something like that?

    Use of reserved word "our" is deprecated at code.pl line 2.
    Can't modify subroutine entry in scalar assignment at code.pl line 2, near "'main::er';"
    BEGIN not safe after errors--compilation aborted at code.pl line 3.

    SunOS 5.7

    Update:Ok, thanks wog.
    Now it's causing a core dump, I guess I really should update to perl 5.6

    The 15 year old, freshman programmer,
    Stephen Rawls

      It requires perl version 5.6.0 or higher. It sounds like you are using a version that predates that. It should work if you just remove the "our" on the first line.

      (update:) then again, tests don't reveal that:

      fred$ perl #!/usr/bin/perl -w package DB;$sub='main::er';sub BEGIN {$^P=1 unless$sub; $^P or $_="Not just another perl hack"}sub sub(hack){print $sub =~ /([^:]+)$/, $", or &$sub} *hacker = \&sub; package main;sub er {print ",\n"}sub just {for(split' '=>`perldoc` ){print $1 if /(\w{4})\d\w/;}}sub hack {print "hacker"}sub another { seek DATA, 0, 0;print +(/(\w{6})\d/)?'':$1 while <DATA>;DB::hacker();}sub perl { print }$_ and print "$_\n" ;foreach (qw{just another perl hack}) {$_->();}print "\n";
      (control-D)
      Segmentation fault fred$ perl -v This is perl, version 5.005_02 built for sun4-solaris-thread

      Weird.

        She kinda work now, I get:

        just another perl hack CODE(0x1785a40)

        better than the infinitely boring loop it generated before. My Perl remains 5.6.0.

        tachyon