Obfuscated Perl in PBP

A

amirkarger

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
 
D

DJ Stunks

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
 
A

amirkarger

DJ said:
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
 
A

A. Sinan Unur

(e-mail address removed) wrote in @v46g2000cwv.googlegroups.com:
DJ said:
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 <[email protected]>
(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

amirkarger

Ferry said:
Amir Karger:


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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top