Perl as modules

geoff on 2002-12-24T16:01:57

so I'm doing a proposal review for (yet another) generic Perl book (actually, it would be repackage of one that's already out there, but everyone needs to go through the motions anyway). one of the things that struck me while looking over the TOC was that the chapter on file handling discusses Perl's built-in functions almost exclusively - modules like IO::File are left to a chapter on standard modules.

When I really sat down to analyze this, it actually bothered me quite a bit (though it's not the author's fault). Are there any books that teach Perl as a language and include standard modules from the start? Do they discuss localtime right alongside the core Time:: modules, core Text:: with string manipulation, Test:: with "how to write a Perl program"? I admit it's been a very long time since I've actually looked at a beginning Perl book, but making core modules just an aside seemed like a real disservice to novices all of a sudden.


Modules for begineers

Odud on 2003-01-15T16:23:00

Sorry for late replies, but I'm still catching up with the holidays....

Similar thoughts occurred to me. I'm coaching a beginner in Perl. We've done all the usual stuff, files, arrays, hashes, matches, regexes etc. and I'm just wondering when and how to introduce modules. IMHO most books leave it too late - and drop it in just when the reader is starting to feel confident and WHAM! - but put it in too early when the reader is just beginning to understand and WHAM!WHAM!
I also think it is a mistake to tie it too closely to OO. I've heard other people at work say "Oh I don't need modules, because it isn't OO based".

Re:Modules for begineers

geoff on 2003-01-15T17:16:10

yeah, it's a difficult topic to describe well. I've heard that Sam Tregar's Writing Perl Modules for CPAN does a good job, but I've not yet read it.

and yes, modules do not (necessarily) equal OO. A good example is File::Spec which provides both functional and OO interfaces. modules as libraries is really the direction I was headed - for OO stuff Object-Oriented Perl is the best resource and there's no reason to try and repeat that work again.