Tricky AUTOLOAD behavior

Discussion in 'Perl' started by Jim Schueler, Aug 25, 2004.

  1. Jim Schueler

    Jim Schueler Guest

    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
     
    Jim Schueler, Aug 25, 2004
    #1
    1. Advertising

  2. Jim Schueler

    Guest

    (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.
     
    , Aug 25, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mdudlik

    Autoload to a different frame

    mdudlik, Jun 6, 2004, in forum: HTML
    Replies:
    0
    Views:
    422
    mdudlik
    Jun 6, 2004
  2. Thomas Schneider

    Autoload Page outside of Frameset

    Thomas Schneider, Jun 2, 2005, in forum: HTML
    Replies:
    6
    Views:
    2,911
    Thomas Schneider
    Jun 8, 2005
  3. Replies:
    9
    Views:
    549
    CBFalconer
    Apr 25, 2006
  4. Wybo Dekker

    tk/autoload not found

    Wybo Dekker, Jul 12, 2004, in forum: Ruby
    Replies:
    4
    Views:
    167
    Hidetoshi NAGAI
    Jul 13, 2004
  5. J Krugman

    *{$AUTOLOAD} vs *$AUTOLOAD

    J Krugman, Jul 13, 2005, in forum: Perl Misc
    Replies:
    1
    Views:
    102
    Tassilo v. Parseval
    Jul 14, 2005
Loading...

Share This Page