Obfuscated Perl in PBP

Discussion in 'Perl Misc' started by amirkarger@gmail.com, May 16, 2006.

  1. Guest

    Rather than spend my time reading Perl Best Practices, I decided to
    play with the obfuscated code on p. 19. I can't imagine someone would
    spend the time to write it if it doesn't do anything, but when I run
    it, it just prints "No\n", which isn't very exciting.

    In particular, the very beginning,
    $;=$/;seek+DATA,undef$/,!$s;$_=<DATA>;
    doesn't seem to get anything in $_ because there's no __DATA__ section.

    So, do you need to call it with special input, is there a certain
    version it works with, did I type it in incorrectly (How come they
    didn't include it in the code tarball from O'Reilly?), or what?

    "I must know."

    -Amir Karger
     
    , May 16, 2006
    #1
    1. Advertising

  2. DJ Stunks Guest

    wrote:
    > Rather than spend my time reading Perl Best Practices, I decided to
    > play with [myself]


    Rather than spend my time reading the remainder of this post I decided
    to ignore any and all requests made by you in the future.

    -jp
     
    DJ Stunks, May 16, 2006
    #2
    1. Advertising

  3. Guest

    DJ Stunks wrote:
    > wrote:
    > > Rather than spend my time reading Perl Best Practices, I decided to
    > > play with [myself]

    >
    > Rather than spend my time reading the remainder of this post I decided
    > to ignore any and all requests made by you in the future.
    >
    > -jp


    Awesome! I haven't been kill-filed since I complimented Baby Bop on
    alt.barney.die.die.die!

    -Amir
     
    , May 16, 2006
    #3
  4. wrote in news:1147808272.920848.280930
    @v46g2000cwv.googlegroups.com:

    >
    > DJ Stunks wrote:
    >> wrote:
    >> > Rather than spend my time reading Perl Best Practices, I decided to
    >> > play with [myself]

    >>
    >> Rather than spend my time reading the remainder of this post I
    >> decided to ignore any and all requests made by you in the future.


    ....

    > Awesome! I haven't been kill-filed since I complimented Baby Bop on
    > alt.barney.die.die.die!


    And today, you get two for the price of one.

    Sinan

    --
    A. Sinan Unur <>
    (remove .invalid and reverse each component for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, May 16, 2006
    #4
  5. Guest

    Ferry Bolhar wrote:
    > Amir Karger:
    >
    > > In particular, the very beginning,
    > > $;=$/;seek+DATA,undef$/,!$s;$_=<DATA>;
    > > doesn't seem to get anything in $_ because there's no __DATA__ section.

    >
    > And who tells you that this isn't expected behaviour? Reading from
    > <DATA> when there is no __DATA__ section is the same as reading
    > from a filehandle which was opened for an empty file or when the file
    > end was reached already - it just returns "undef" and sets the EOF
    > condition true for the filehandle.


    Well, IF there's a __DATA__ section, then seek undef $/, 1; $_=<DATA>
    does in fact get you the entire program (including whatever's in
    __DATA__). But without a __DATA__ section, you don't get anything. So
    yes, I've seen obfuscated examples that do this, but I don't see how
    you can get anything useful without a __DATA__. Which is why I feel
    like I must be missing something.

    >
    > I havn't the "Best Practices" book here, so I can't look for the
    > example, but I have seen many obfuscated examples for printing
    > out "Just another Perl hacker", wherein often the code works
    > just by using more or less documented side-effects in constructs.
    > So while the code snippet you posted makes no sense at the first
    > view, this doesn't mean that it will not make sense in the entire
    > example.
    >
    > It's up to you to get the solution... :)


    I can play with putting stuff in __DATA__. But figuring out what code
    does when you don't even have the whole program is even harder!

    There was definitely no __DATA__ in the example. (In fact, the example
    was about code indentation, and had a boss sending email to "you"
    saying, "I came across this chunk of code in your lateset module...."
    and '>' quoting the code.

    -Amir
     
    , May 17, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    683
  2. chris kramer
    Replies:
    5
    Views:
    562
    chris kramer
    Apr 9, 2004
  3. fix

    Obfuscated xsl

    fix, Nov 27, 2003, in forum: XML
    Replies:
    4
    Views:
    584
    Patrick TJ McPhee
    Nov 28, 2003
  4. Thomas Garai

    obfuscated c/c++

    Thomas Garai, Jun 22, 2004, in forum: C++
    Replies:
    5
    Views:
    476
    Prateek R Karandikar
    Jun 22, 2004
  5. G. Nick D'Andrea

    Obfuscated Languages Interpreter

    G. Nick D'Andrea, Jun 30, 2003, in forum: C Programming
    Replies:
    3
    Views:
    739
    David Rubin
    Jul 2, 2003
Loading...

Share This Page