part but, unfortunately it executes the script.plperl -d:Modlist=options script.pl perl -MDevel::Modlist=options script.pl # equivalent
Enjoy the results!#!perl #use strict; #commented to not pollute %INC #use warnings;#commented to not pollute %INC my $file = $ARGV[0]; my $content = do { open my $fh, '<', $file or die $!; local $/; <$fh> +}; my $begin =<<'THEEND'; UNITCHECK { no strict; # access $VERSION by symbolic reference no warnings qw (uninitialized); print map { s!/!::!g; s!.pm$!!; sprintf "%-20s %s\n", $_, ${"${_}::VERSION"} } sort keys %INC; exit; }; THEEND eval $begin.$content; print $@ if $@;
L*perl -c -e "BEGIN{print qq(1-begin\n)}; UNITCHECK {print qq(2-unitcheck\n)}; CHECK {print qq(3-check\n)}; INIT {print qq(4-init\n)}; print qq(5-main\n); END{print qq(6-end\n)}" __OUTPUT__ 1-begin 2-unitcheck 3-check -e syntax OK # the same code without -c __OUTPUT__ 1-begin 2-unitcheck 3-check 4-init 5-main 6-end
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: check modules used by a script and their version
by Tux (Canon) on Apr 03, 2014 at 10:35 UTC | |
by Discipulus (Canon) on Apr 03, 2014 at 10:40 UTC | |
by davido (Cardinal) on Apr 03, 2014 at 16:17 UTC | |
Re: check modules used by a script and their version
by Discipulus (Canon) on Apr 09, 2014 at 07:02 UTC |