Don't ask to ask, just ask | |
PerlMonks |
checking for all packagesby Wiggins (Hermit) |
on May 16, 2014 at 17:45 UTC ( [id://1086368]=perlquestion: print w/replies, xml ) | Need Help?? |
Wiggins has asked for the wisdom of the Perl Monks concerning the following question:
This is a vague request that search couldn't help with. I am sure you will be able. I want to create a 'here' document/program that will determine ALL of the missing packages from a set of specified packages in 1 run. Not the first only, per run. This is a pre-test in an installation script. Simple. I will assume that if the named package is present, the dependencies are also loaded. --Solution-- The replies I received were just what I was hopeing for. 4 very different approaches. For my usual projects, I try to support the largest number of OS default installations. That means that I avoid using non-Core packages. Two of the solutions provided involve non-core packages, which will not be present in a default install, or possibly in one where additional packages requested were not installed. That leaves two remaining solutions. The first involved a loop arround an 'eval', which is pretty much what I expected. The second was a nesting of 'map' 'grep' 'map' eval require. Both solution worked (on a core only Perl install) and supplied approximately the same information. Using the HOP principal of being wary of 'extreme cleverness' (for future maintenance reasons), I choose the classic "looped eval require" solution Thank you all, I will be digging into the one liner for my own edification. It is always better to have seen your target for yourself, rather than depend upon someone else's description.
Back to
Seekers of Perl Wisdom
|
|