|Perl Monk, Perl Meditation|
Re: Question about the most efficient way to read Apache log files without All-In-One Modules from CPAN (personal learning exercise)by sundialsvc4 (Abbot)
|on Jun 17, 2015 at 13:54 UTC||Need Help??|
Also: “Yay!! This is open source! Therefore, you can see for yourself!” :-)
Simply look-up any of those modules on http://search.cpan.org, then click on the Source hyperlink at the top of the page, next to the version-number. Presto: there’s the source. Wanna know what they did and how they did it? There are no secrets. Wanna look at the test-suite that runs anytime the package is installed on a computer? No secrets.
Now, you might well have stumbled-upon a package which is actually part of another package, such that “the source” actually consists of the whole package. Well, there’s a hyperlink to that, too ... closer yet to the top of the page, next to the author’s name.
The source-code to any installed package can also be found in the library directories of your computer. The PERL5LIB environment-variable (or its equivalent, found in some control-panel, in Windows), will tell you where.
Some libraries actually use a combination of “pure Perl” and C/C++ subroutines, in a technique called “XS.” Nevertheless, all the relevant source-code should be right there, along with the “magick glue” that links the two together.
While you’re getting-to-know Perl, another “must have” CPAN module (family ...) to be aware of is: Regexp::Common. (Definitely “click next to the author’s name” on this one! It’s big!) A library of many hundreds of commonly-used regular expressions, all of them well-tested so that you don’t have to.
Although it is, indeed, very educational to “learn from the working examples of others,” it’s also important to “do not do a thing already done.” CPAN-provided solutions are frequently very thorough, very complete, and very tested. One might cautiously say that “the Perl language, itself,” is rather ordinary . . . but “the CPAN library” is one of the biggest-and-best in our industry. “What’s all the fuss about, really?” To me, the answer is: CPAN. Learn it well, use it often.
Welcome to the Monastery!