What!?! Code after __END_ ???

J

J Krugman

When will Perl wonders *EVER* cease?

Despite *years* of programming in Perl I still come across legit
Perl code that I find as unfathomable as if I had just started
programming Perl one hour ago. And I'm not talking about the winner
of the Obfuscated Perl Contest.

What blindsids me this time around is in the CPAN module
Class::MethodMaker (v 1.12). About 90% of the code in
Class/MethodMaker.pm, which accounts for all the "supported methods"
for this module according to its documentation, appears *after*
the lines

1; # keep require happy

# ----------------------------------------------------------------------------

__END__

(See
http://search.cpan.org/src/FLUFFY/Class-MethodMaker-1.12/lib/Class/MethodMaker.pm.
The code for the most recent version of MethodMaker does the same
thing with __END__.)

What on earth is going on here? Every documentation I've managed
to find for __END__ says that the compiler doesn't go beyond it.
In the source prior to the __END__ there is no reading from <DATA>
and eval-ing the read text, and besides, this is a module not a
script, so reading from <DATA> would not work anyway.

How can this module work at all???

TIA!

jill
Perennial Perl Beginner
 
A

Andy Hassall

When will Perl wonders *EVER* cease?

Never, hopefully :)
Despite *years* of programming in Perl I still come across legit
Perl code that I find as unfathomable as if I had just started
programming Perl one hour ago. And I'm not talking about the winner
of the Obfuscated Perl Contest.

What blindsids me this time around is in the CPAN module
Class::MethodMaker (v 1.12). About 90% of the code in
Class/MethodMaker.pm, which accounts for all the "supported methods"
for this module according to its documentation, appears *after*
the lines

1; # keep require happy

# ----------------------------------------------------------------------------

__END__

(See
http://search.cpan.org/src/FLUFFY/Class-MethodMaker-1.12/lib/Class/MethodMaker.pm.
The code for the most recent version of MethodMaker does the same
thing with __END__.)

What on earth is going on here? Every documentation I've managed
to find for __END__ says that the compiler doesn't go beyond it.
In the source prior to the __END__ there is no reading from <DATA>
and eval-ing the read text, and besides, this is a module not a
script, so reading from <DATA> would not work anyway.

How can this module work at all???

http://search.cpan.org/~nwclark/perl-5.8.6/lib/AutoLoader.pm
"
To use AutoLoader, the author of a module has to place the definitions of
subroutines to be autoloaded after an __END__ token.
"


http://search.cpan.org/src/FLUFFY/Class-MethodMaker-1.12/lib/Class/MethodMaker.pm
"
use AutoLoader 'AUTOLOAD';
"
 

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

Forum statistics

Threads
474,166
Messages
2,570,901
Members
47,442
Latest member
KevinLocki

Latest Threads

Top