Tricky AUTOLOAD behavior

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Schueler

    Tricky AUTOLOAD behavior

    Here is some sample code that uses inherited class methods:


    package parseHTML ;

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


    package parseASP ;

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

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

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

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

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

    &parseASP::doPa rse() ;


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

    If I delete the last function, parseASP::docom ment(), then the inherited
    function parseHTML::doco mment() 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
  • nobull@mail.com

    #2
    Re: Tricky AUTOLOAD behavior

    jschueler@tqis. com (Jim Schueler) writes exactly the same thing he
    wrote 4 days ago....[color=blue]
    > Here is some sample code that uses inherited class methods:[/color]

    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.

    Comment

    Working...