sub isModuleInstalled($) { my $module = shift; my $true = 1; my $false = not $true; eval( 'use ' . $module ); if ($@) { print $module. " is not installed\n"; return $false; } else { print $module. " is already installed\n"; return $true; } }
sub isModuleVersion($) { my $module = shift; my $true = 1; my $false = not $true; eval( 'use ' . $module ); if ($@) { print $module. " is not installed\n"; return $false; } else { print $module. " is already installed\n"; eval "require $module"; if($@) { return $false; } else { return $module->VERSION; } } }
留言
perl -MLWP::UserAgent -e ‘print LWP::UserAgent->VERSION;’