Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Tricky AUTOLOAD behavior

Reply
Thread Tools

Tricky AUTOLOAD behavior

 
 
Jim Schueler
Guest
Posts: n/a
 
      08-25-2004
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
 
Reply With Quote
 
 
 
 
nobull@mail.com
Guest
Posts: n/a
 
      08-25-2004
http://www.velocityreviews.com/forums/(E-Mail 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
a tricky if else(maybe not tricky but impossible) nirkheys@gmail.com C Programming 9 04-25-2006 06:13 PM
*{$AUTOLOAD} vs *$AUTOLOAD J Krugman Perl Misc 1 07-14-2005 06:09 AM
Autoload Page outside of Frameset Thomas Schneider HTML 6 06-08-2005 02:58 PM
Autoload to a different frame mdudlik HTML 0 06-06-2004 01:51 AM
CD Autoload IHSRC Computer Support 0 01-08-2004 02:46 AM



Advertisments