Syntactic Confectionery Delight | |
PerlMonks |
Re: Re: Using modules for Newbiesby mattr (Curate) |
on Apr 20, 2003 at 15:04 UTC ( [id://251823]=note: print w/replies, xml ) | Need Help?? |
The line starting with "my $seti" is using the idiom of Object Oriented programming.
I recommend reading a tutorial on Object Oriented Perl here at the Monastery. The third one in the list was also recommended by Louis_Wu above.
Anyway to be brief, it is a very useful way to deal with data and subroutines (or "methods") as belonging to a metaphorical object. In this case a new object is being created based on the WebStats object template by calling WebStats' object constructing subroutine (called "new"). The arrow means "the WebStats method called ..." and the ampersand which normally preceeds a subroutine you are calling is left out by convention. The constructor method is given an email address and returns a WebStats object, which gets put into $seti. $seti is now an object which knows everything a WebStats object should know, like its email address (which you told it) and how many units it has processed. It has a method (a subroutine) called "numResults" which when called returns the number of units processed. You will find that you can do an awful lot of things with the CPAN (www.cpan.org) and just this knowledge, but I *urge* you to read the above tutorial and some of the very good books or online sites recommended by the nice monks above. Perl.com does have a Documentation page, also perldoc.com has all the manuals that come with perl. But amazingly enough, as Juerd told you there is a whole book online for free! Can you imagine it! Chapter 11 is all about Object-Oriented Perl. Run, don't walk to it. We can answer individual questions but you will be able to make the most out of Perlmonks (and the CGI.pm module, and ..) if you take advantage of these wonderful resources.
In Section
Seekers of Perl Wisdom
|
|