Inherited class methods and special variables

From: Jim Schueler (jschueler_at_tqis.com)
Date: 08/18/04

  • Next message: Greg G: "NDBM_File file not found?"
    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


  • Next message: Greg G: "NDBM_File file not found?"

    Relevant Pages

    • Tricky AUTOLOAD behavior
      ... Here is some sample code that uses inherited class methods: ... package parseHTML; ... sub parseHTML::docomment { ... the code outputs a bunch of blank lines. ...
      (comp.lang.perl)
    • RE: Uploading a Picture
      ... List Disk Drives ... The following sample code uses a StreamReader class to read the System.ini ... Dim ... End Sub ...
      (microsoft.public.vb.database)
    • Re: Dynamically add link button
      ... You may want to check out some sample code I've placed on my website. ... "simon" wrote in message ... > false.When user click the button set visibility to true and when choose ... >>> Private Sub Page_Load(ByVal sender As System.Object, ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: PowerPoint VBA
      ... Here is some sample code. ... ' Remember you need to set a reference to Outlook in the VBE window. ... Sub MailThruOutlook() ... Bill Foley, Microsoft MVP ...
      (microsoft.public.powerpoint)
    • Statusbar
      ... In the below sample code, how do i determine/translate the "# of items to ... Sub TestBar() ... StatBar i, MyTot, "Processing", True ' display statusbar ... ' previous line speeds up the macro by not updating the statusbar for ...
      (microsoft.public.excel.programming)