Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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 ( #1130809=note: print w/replies, xml ) Need Help??


in reply to Question about the most efficient way to read Apache log files without All-In-One Modules from CPAN (personal learning exercise)

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!

  • Comment on Re: Question about the most efficient way to read Apache log files without All-In-One Modules from CPAN (personal learning exercise)

Replies are listed 'Best First'.
Re^2: Question about the most efficient way to read Apache log files without All-In-One Modules from CPAN (personal learning exercise)
by kcott (Chancellor) on Jun 17, 2015 at 19:38 UTC
    "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."

    No, that's wrong!

    @INC contains the directories. These directories include whatever's in $PERL5LIB if it's been set or in $PERLLIB if that's been set.

    This is documented in perlrun: ENVIRONMENT:

    PERL5LIB
    A list of directories in which to look for Perl library files before looking in the standard library and the current directory.
    ...
    If PERL5LIB is not defined, PERLLIB is used. ...
    PERLLIB
    A list of directories in which to look for Perl library files before looking in the standard library and the current directory. If PERL5LIB is defined, PERLLIB is not used. ...

    You can confirm this with perl -V (look under %ENV: and @INC: at the end of the output).

    Please check your information before posting.

    -- Ken

Re^2: Question about the most efficient way to read Apache log files without All-In-One Modules from CPAN (personal learning exercise)
by marinersk (Priest) on Jun 18, 2015 at 05:12 UTC

    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.

    Uhm...no. I can assure you CPAN modules are not installed in the directory where my personal Perl modules are stored; but rather, in the lib directory under my various Perl installations. While this might be hinted at by the PATH environment variable (as seen in the example below), this is not assured. You can install Perl in a directory called M:\Booger.x , if you were so inclined.

    Also, under Windows, you needn't go to the System Control Panel Environment options screen to examine environment variables; they are still available in the command shell in much the same way they've always been, using the SET command:

          D:\PerlMonks>set | grep -i "perl"
    Path=C:\Steve\Utils;C:\cygwin\bin;C:\App\Java\jdk1.7.0_55\bin;C:\Perl\Perl-5.18.2.1802\site\bin;C:\Perl\Perl-5.18.2.1802\bin;c:\Program Files (x86)\Intel\iCLS Client\;c:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management EngineComponents\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\
    PERL5LIB=C:/Steve/Perl
    D:\PerlMonks>
         

    Update: This in contrast to the @INC values mentioned by kcott above:

         
    D:\PerlMonks>perl -e "print qq(@INC)" C:/Steve/Perl C:/Perl/Perl-5.18.2.1802/site/lib C:/Perl/Perl-5.18.2.18 +02/lib . D:\PerlMonks>
         

Re^2: Question about the most efficient way to read Apache log files without All-In-One Modules from CPAN (personal learning exercise)
by Anonymous Monk on Jun 17, 2015 at 14:26 UTC
    it’s also important to “do not do a thing already done.”

    Who are you quoting there?

    I'd like to look up why they think it is important to not do a thing already done.

      See also "re-inventing the wheel." This applies less to a learning exercise than production code produced under time pressure.

      Dum Spiro Spero

        See also "re-inventing the wheel." This applies less to a learning exercise than production code produced under time pressure.

        So GotToBTru is sundialsvc4 ?

        How does that answer the question Who are you quoting there?

      Frankly, for a beginner (which is ostensibly one of our key target audiences), I would encourage doing a thing already done, so you can compare how you approached the problem to those who have come before you.

      Most people learn by doing; or, perhaps more accurate to say that they cement their learnings by doing.

      So I, for one, take the opposite stance: It is vitally important for most beginners to do many things already done. That's how they develop their art.

      Plus, on the everpresent practical note, sometimes you can't use CPAN modules. We've hashed that over and over here at the Monastary for years; but the truth is sometimes you don't have the option to drink deeply from the CPAN well.

      At which point you need to have your art reasonably well-developed, as you will be re-inventing that wheel, and it sure would be nice if you made a decent showing of yourself in the process.

Re^2: Question about the most efficient way to read Apache log files without All-In-One Modules from CPAN (personal learning exercise)
by lulz (Initiate) on Jun 17, 2015 at 19:07 UTC
    Thank you for your reply!

    I have been looking at Apache ParseLog from CPAN and then read the comments. Then i switched over to App::YG::Apache, whose parser is much much more elegant and readable, but limited to one case. I know from my limited experience that the Perl regex machine is extremely fast when it comes to finding matches, but can take quite a long time for failures, so I was thinking, for a more general case, if there was yet another way to parse these files that might be faster without using regular expressions that I could play around with.

Re^2: Question about the most efficient way to read Apache log files without All-In-One Modules from CPAN (personal learning exercise)
by karlgoethebier (Prior) on Jun 17, 2015 at 20:12 UTC
    “What’s all the fuss about, really?”

    Indeed.

    «The Crux of the Biscuit is the Apostrophe»

      You're on dangerous ground here karlgoethebier , don't paradox you'll destroy the universe!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1130809]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2018-01-16 15:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (182 votes). Check out past polls.

    Notices?