If you're on Linux (with a kernel newer than 2.6.13) you might be able to use inotify via Linux::Inotify2 for this. You'd have to write a daemon which is running continually and logs/counts access times as they occur, but this should not be a significant drain on system resources. (Disclaimer: I've not used Linux::Inotify2, so don't know how well it works, but at least it seems to be somewhat actively maintained). If you're willing to use a non-perl tool, maybe inotifywatch from the inotify-tools will do you.
Mind you, I do see a problem with the whole approach concerning long-running processes using your Perl modules. For example, if this is a web server running Apache and mod_perl, it will only access the Perl module once (the first time it is loaded) and not change the access time of the module again unless Apache is restarted (which for a well-maintained server could be weeks), regardless of how often the module gets called. For this kind of scenario you'll need a different approach.
Update: Ah, I see almut beat me to it ;-). Just a note concerning performance, from what I know of inotify I'd guess that having a process watch all Perl modules (with less than many thousand accesses a day) would be less resource intensive than going through the whole of @INC once a night. Granted, you probably don't care about resources used at night, but still, inotify is more elegant.
And to be honest, now that you've said why you want to do this, I'd question the wisdom of wanting to do it any way. Are your servers really that constrained for disk space that you need to cut down on the number of Perl modules installed? On any modern machine the disk space consumed thereby should be far too little to really make it worth the bother.
In reply to Re: tracking module usage
by tirwhan
in thread tracking module usage
by pileofrogs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |