package_name->new(); a basic language queston

W

werwer

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.
 
S

sheinrich

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
 
W

werwer

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.
 
X

xhoster

werwer said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,209
Messages
2,571,088
Members
47,684
Latest member
sparada

Latest Threads

Top