in reply to Indirect variable expansion
Just as another answer my personal pmver shell function. Exits with error if any of the named modules aren't available.
pmver () { perl -le '$exit=0;for $f (@ARGV) { eval qq{require $f}; if( $@ + =~ /locate (\S+)\.pm/ ) { print qq{$f not installed}; $exit=1;next} +print qq{$f: },${"${f}::VERSION"}||q{undefined}}exit $exit' "$@" }
Edit: Apt point below. Historically I've used this checking if/what CPAN stuff's installed so that was my expected failure mode WRT require. A more bullet proof version would probably report $@ in any failure (and/or use Try::Tiny).
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Indirect variable expansion
by Corion (Patriarch) on Nov 18, 2024 at 07:00 UTC |