[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Introduction - use of modules




6/30/99, madame philosophe wrote:
  >Does anyone have any comments or advice about that?

Madame,

I've been following most of the suggestions on this thread, and I'm sure
you must be pleased that so many people are willing to take the time to
share their experience.

I just wanted to toss in a slightly different angle, based on what's worked
for me during the initial ramp-up period.

When it comes to searching CPAN, downloading and installing modules, and
learning OO, I agree with the general drift of leaving that till later, and
to start by writing your own code.

But I make an exception for modules that come packaged with perl, and that
are nicely documented in the Perl Cookbook.  If you need to visit the files
of a directory, for example, you can find that topic readily in the
Cookbook and it will tell you about File::find.  I'd recommend using these
conveniently accessible modules, so your practice code can be more related
to your area of interest, instead of grunging around in low-level details
that someone else has already handled and you may _never need to know about.

One module that is particularly useful, if you want to do any processing of
html documents, is HTML::Parser.  The drawback which scares many people
away is that it _is OO and _does require a subclass to be written in order
to make use of it.

I've helped a few people over that hurdle - it's not really a big one in
this case.  But I've also written a cover-module that makes the
functionality available in a non-OO way.  You just call it twice, once with
a list of call-back routines, and again to start the parsing:

    my $Doc = ParseHTML->new( \&StartTag, \&EndTag, \&TextSnip ) ;
    $Doc->parse_file( $SourceFile ) ;

Then your subs get called for each token as it is parsed, and control then
resumes after the $Doc->parse_file statement.

The cover module is only about a page and a test script is another page.
I'd be glad to post it or send it to anyone interested, depending on
response.


good luck,
rkm


===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org