in reply to $VERSION to logfile?
#!/usr/bin/perl -w use strict; my @modules = qw( File::Copy File::Find File::Foo File::Spec File::Temp ); for my $module (@modules) { my $version; eval "require $module"; if (not $@) { $version = $module->VERSION; $version = '(unknown)' if not defined $version; } else { $version = '(not installed)'; } print $module, "\t", $version, "\n"; } __END__ Prints: File::Copy 2.03 File::Find (unknown) File::Foo (not installed) File::Spec 0.82 File::Temp 0.12
In your example you should check the $@ variable, see perlvar, after using eval to see if there was as error:
print "Eval error: ", $@ if $@;
--
John.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: $VERSION to logfile?
by tenya (Beadle) on Apr 17, 2003 at 03:57 UTC |