Leser: 5
|< 1 2 3 >| | 26 Einträge, 3 Seiten |
1
2
3
4
5
6
7
sub FindPerlModule
{
my ($Modul) = @_;
my $ModulStatus = "";
$ModulStatus = (eval "require $Modul" ? "OK" : "NOT INSTALLED");
return $ModulStatus;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /usr/bin/perl
use strict;
use warnings;
my $modul = 'CGI';
my ($status,$vers) = FindPerlModule($modul);
print $modul," ",$vers," -> ",$status,"\n";
sub FindPerlModule
{
my ($Modul) = @_;
my ($ModulStatus,$vers);
if(eval("require $Modul")){
$vers = ${Modul}->VERSION || 0;
$ModulStatus = "OK";
}
else{
$vers = 0;
$ModulStatus = "NOT INSTALLED";
}
return ($ModulStatus,$vers);
}
$ModulVersion = ${Modul}->VERSION || 0;
1
2
3
4
5
6
C:\>perl -MCGI -e "print $CGI::VERSION;"
2.81
C:\>perl -MCGI -e "print CGI->VERSION;"
2.81
C:\>perl -MCGI -e "print $CGI->VERSION;"
Can't call method "VERSION" on an undefined value at -e line 1.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
sub getVersion {
my $file = shift;
my $c = "";
open(MOD, $file) or die $!;
my $inpod = 0;
my $result;
# Thieved from Module::Info which itself thieved from
# ExtUtils::MM_Unix 1.12603
while (<MOD>) {
$inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
next if $inpod || /^\s*#/;
chomp;
next unless /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
my $eval = qq{
package vTree::_version;
no strict;
local $1$2;
\$$2=undef; do {
$_
}; \$$2
};
$c = $1 if/(#.*$)/;
local $^W = 0;
$result = eval($eval);
warn "Could not eval '$eval' in $parsefile: $@" if $@;
$result = "undef" unless defined $result;
last;
}
close MOD;
return ([$result,$c]);
}
|< 1 2 3 >| | 26 Einträge, 3 Seiten |