check modules used by a script and their versionby Discipulus (Curate)
|on Apr 03, 2014 at 10:26 UTC||Need Help??|
another CUFP or better WICDWMBP (what i can do with my baby Perl)..
Reading this post i'm started wondering if there was a way to wrap an existing script and grab modules it uses without exucuting it.
Obviously the answer or part of it was in the monastery: here
I very liked the
part but, unfortunately it executes the script.pl
Also liked the tachyon-II hack, but you have to edit the script.pl and i'm too lazy.
No hope to use $^C = 1 as pointed wisely by shmem
The UNITCHECK do the trick! Never known it seems quite usefull for this task: read about it
Enjoy the results!
UPDATE 9 april 2014: BE CAREFULL, as stated by davido and also by LanX in other post, BEGIN blocks are executed anyway. In fact BEGIN blocks come first, in order of definition, then come UNITCHECK blocks and, being that block prepended to the original code in the above program, it will be executed just after the last BEGIN block and just before any UNITCHECK defined in the original program passed in via @ARGV. In the case of perl -c -d:TraceUse script.pl all the BEGIN UNITCHECK CHECK blocks are executed.
Here two examples to demonstrate where the -c ends his operations (a simplified version of 16 pillars of wisdom):
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.