Inherited class methods and special variables
From: Jim Schueler (jschueler_at_tqis.com)
Date: 08/18/04
- Previous message: penguinista: "Re: embedding Perl"
- Next in thread: nobull_at_mail.com: "Re: Inherited class methods and special variables"
- Reply: nobull_at_mail.com: "Re: Inherited class methods and special variables"
- Reply: nobull_at_mail.com: "Re: Inherited class methods and special variables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 18 Aug 2004 11:20:12 -0700
Here is some sample code that uses inherited class methods:
sub parseHTML::docomment {
my $comment = shift ;
print $comment, "\n" ;
}
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" ;
}
&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
- Previous message: penguinista: "Re: embedding Perl"
- Next in thread: nobull_at_mail.com: "Re: Inherited class methods and special variables"
- Reply: nobull_at_mail.com: "Re: Inherited class methods and special variables"
- Reply: nobull_at_mail.com: "Re: Inherited class methods and special variables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|