package_name->new(); a basic language queston

Discussion in 'Perl Misc' started by werwer, Mar 2, 2008.

  1. werwer

    werwer Guest

    This isn't about PerlSAX, but a package construct I found there in an
    example using the module. I have no idea what's going on here so I'm
    guessing. This appears in the code

    my $handler = SaxHandler->new();

    But there is no SaxHandler anywhere in the documentation ..... but
    wait! Later in the code the author defines a package as in

    package SaxHandler;

    and in this package are subroutines with names of the callbacks, the
    SAX event handling routines, that SAX will call for each different XML
    event (starting ending new final ....)

    I had no idea a package name could be used in such a fashion. I
    appreciate some short discussion of what's going on. Thanks.
    werwer, Mar 2, 2008
    #1
    1. Advertising

  2. werwer

    Guest

    On Mar 2, 5:12 pm, werwer <> wrote:
    > This isn't about PerlSAX, but a package construct I found there in an
    > example using the module. I have no idea what's going on here so I'm
    > guessing. This appears in the code
    >
    > my $handler = SaxHandler->new();
    >
    > But there is no SaxHandler anywhere in the documentation ..... but
    > wait! Later in the code the author defines a package as in
    >
    > package SaxHandler;
    >
    > and in this package are subroutines with names of the callbacks, the
    > SAX event handling routines, that SAX will call for each different XML
    > event (starting ending new final ....)
    >
    > I had no idea a package name could be used in such a fashion. I
    > appreciate some short discussion of what's going on. Thanks.


    Welcome to the world of OOP!
    :))

    perldoc perltoot

    would be one of many possible places to start with.

    Cheers, Steffen
    , Mar 2, 2008
    #2
    1. Advertising

  3. werwer

    werwer Guest

    > Welcome to the world of OOP!
    > :))
    >
    > perldoc perltoot
    >
    > would be one of many possible places to start with.
    >
    > Cheers, Steffen


    Ahhhh.... yes yes. Thanks. I had never seen it done that way. It
    was always in a different file. Ok, makes a some sense now. Damn,
    I'm getting old.
    werwer, Mar 2, 2008
    #3
  4. werwer

    Guest

    werwer <> wrote:
    > This isn't about PerlSAX, but a package construct I found there in an
    > example using the module. I have no idea what's going on here so I'm
    > guessing. This appears in the code
    >
    > my $handler = SaxHandler->new();
    >
    > But there is no SaxHandler anywhere in the documentation ..... but
    > wait! Later in the code the author defines a package as in
    >
    > package SaxHandler;
    >
    > and in this package are subroutines with names of the callbacks, the
    > SAX event handling routines, that SAX will call for each different XML
    > event (starting ending new final ....)
    >
    > I had no idea a package name could be used in such a fashion. I
    > appreciate some short discussion of what's going on. Thanks.


    It probably just means that the author didn't think SaxHandler would be of
    general enough interest to make it a stand-alone module. It is roughly
    like an "Inner class" in Java.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    The costs of publication of this article were defrayed in part by the
    payment of page charges. This article must therefore be hereby marked
    advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
    this fact.
    , Mar 2, 2008
    #4
    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. lezah
    Replies:
    7
    Views:
    751
    Mike Treseler
    Mar 2, 2004
  2. =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?=

    ObjectDataSource queston (posted else where Sorry it was a mistake

    =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?=, Jul 18, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    389
    =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?=
    Jul 18, 2007
  3. Torben Keil

    Queston on script tag

    Torben Keil, Feb 8, 2008, in forum: HTML
    Replies:
    17
    Views:
    825
    dorayme
    Feb 12, 2008
  4. Andy B.

    MVC2 form validation queston

    Andy B., Mar 7, 2010, in forum: ASP .Net
    Replies:
    0
    Views:
    690
    Andy B.
    Mar 7, 2010
  5. Oliver
    Replies:
    0
    Views:
    118
    Oliver
    Jul 19, 2007
Loading...

Share This Page