Tricky AUTOLOAD behavior

J

Jim Schueler

Here is some sample code that uses inherited class methods:


package parseHTML ;

sub parseHTML::docomment {
my $comment = shift ;
print $comment, "\n" ;
}


package parseASP ;

sub parseASP::AUTOLOAD {
use vars qw( $AUTOLOAD ) ;

my $key = $AUTOLOAD ;
my $package = __PACKAGE__ ;
$key =~ s/^${package}::// ;

eval "parseHTML::$key( \@_ )" ;
}

sub parseASP::doParse () {
...
local $/ = undef ;
$content = []
$buf = <HTMLFILE> ;
$buf =~ s|<!--(.*?)-->|'<!-- '.&docomment( $1, $comments ).'-->'|seig
...
}

sub parseASP::docomment {
my $comment = shift ;
print $comment, "\n" ;
}

&parseASP::doParse() ;


The code listed above works fine, outputting each comment of an HTML file.

If I delete the last function, parseASP::docomment(), then the inherited
function parseHTML::docomment() should behave identically. However, this
time, the code outputs a bunch of blank lines.

My best theory is that the first argument, $1, is passed as a reference to a
local special variable that goes out of scope. But common sense tells me that
anything that goes on the stack should still be there when I pull it off.
Having lost my mind trying to figure this out, any insight or explanation
would be greatly appreciated.

-Jim
 
N

nobull

(e-mail address removed) (Jim Schueler) writes exactly the same thing he
wrote 4 days ago....
Here is some sample code that uses inherited class methods:

No, that code didn't use class methods or inhertitance 4 days ago and
it still doesn't.

This newsgroup didn't exist 4 days ago and still doesn't exist (still
see FAQ). Please don't start threads here.
 

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
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top