Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Obfuscated Perl in PBP (http://www.velocityreviews.com/forums/t898009-obfuscated-perl-in-pbp.html)

amirkarger@gmail.com 05-16-2006 05:38 PM

Obfuscated Perl in PBP
 
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


DJ Stunks 05-16-2006 05:45 PM

Re: Obfuscated Perl in PBP
 

amirkar...@gmail.com 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


amirkarger@gmail.com 05-16-2006 07:37 PM

Re: Obfuscated Perl in PBP
 

DJ Stunks wrote:
> amirkar...@gmail.com 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


A. Sinan Unur 05-16-2006 08:21 PM

Re: Obfuscated Perl in PBP
 
amirkarger@gmail.com wrote in news:1147808272.920848.280930
@v46g2000cwv.googlegroups.com:

>
> DJ Stunks wrote:
>> amirkar...@gmail.com 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 <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc...uidelines.html


amirkarger@gmail.com 05-17-2006 12:33 PM

Re: Obfuscated Perl in PBP
 

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



All times are GMT. The time now is 09:06 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.