Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Is there a module which Perl has to load when using any module?

by zentara (Archbishop)
on Apr 29, 2005 at 10:40 UTC ( #452565=note: print w/replies, xml ) Need Help??


in reply to Is there a module which Perl has to load when using any module?

Thanks for all the replies. I did figure out something...just create my own module, and automatically load it with PERL5OPT.

In your bashrc (or whichever) put

export PERL5OPT=-MLogger
Then put this Logger.pm in your PERL5LIB
package Logger; use strict; use warnings; print "Logger\n"; 1;
Of course this is just a rudimentary test. You could put whatever code you wanted in there....something to append to a logfile. I wonder if you would need to flock it, if a bunch of perl scripts were running constantly.

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: Is there a module which Perl has to load when using any module?
by ihb (Deacon) on May 02, 2005 at 22:19 UTC

    I don't understand how this would work. How does use/require interact with Logger?

    ihb

    See perltoc if you don't know which perldoc to read!

      I havn't experimented further with it, but what it does, is allow you to log each Perl script that runs, without any changes to each script. You could then just filter the list of Perl scripts from the log, and search thru them for "use and require statements". That would be an easy way of telling which modules are used on your setup.

      When I have the inclination, I want to experiment around with putting END{} blocks in the Logger module(as Merlyn suggests for printing actual modules loaded, and see if it can be exported to main automatically.(I'm only a module novice, so I may be on a dead-end street here)

      The idea is to monitor a system, running for a few weeks, to see which modules are used, or even "used the most".


      I'm not really a human, but I play one on earth. flash japh

        The idea is to monitor a system, running for a few weeks, to see which modules are used, or even "used the most".

        Oh, I see. That's another task than the one in the OP. Yeah, if that's what you're after then a combination of loading a module through PERL5OPT that adds a logger hook in @INC seems like a working solution.

        ihb

        See perltoc if you don't know which perldoc to read!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://452565]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2021-10-16 06:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (69 votes). Check out past polls.

    Notices?