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