| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
# This script will check if the Perl software installed on the system |
| 4 |
# has the necessary requirements in order to run the program. |
| 5 |
# |
| 6 |
# It works with versions of Perl as old as 4.036. |
| 7 |
# |
| 8 |
# Copyright (c)2000, 2001 Sebastien Aperghis-Tramoni |
| 9 |
|
| 10 |
|
| 11 |
# [ configurable part ] |
| 12 |
|
| 13 |
$needperl = 5.004; |
| 14 |
$program = 'Html2Wml'; |
| 15 |
@files = ('html2wml.cgi'); |
| 16 |
|
| 17 |
# [ end configuration ] |
| 18 |
|
| 19 |
|
| 20 |
sub fatal { print @_; exit -1; } |
| 21 |
sub nonfatal { print @_; } |
| 22 |
|
| 23 |
## Check perl version |
| 24 |
$] =~ /(\d+(\.\d+))/; |
| 25 |
if($1 < $needperl) { |
| 26 |
&fatal("Your version of Perl ($1) is too old. \n", |
| 27 |
"Please upgrade to version $needperl or later. \n"); |
| 28 |
} |
| 29 |
|
| 30 |
## Search for needed modules |
| 31 |
for $file (@files) { |
| 32 |
open(FILE, $file) |
| 33 |
|| &fatal("Can't open program file. Check if your archive is correct. \n"); |
| 34 |
|
| 35 |
%modules = (); |
| 36 |
|
| 37 |
while(<FILE>) { |
| 38 |
chop; |
| 39 |
|
| 40 |
## end of code section |
| 41 |
if(/^__END__/) { last } |
| 42 |
if(/^__DATA__/) { last } |
| 43 |
|
| 44 |
## skip POD sections |
| 45 |
if(/^=head/) { |
| 46 |
do { $_ = <FILE> } until(/^=cut/) |
| 47 |
} |
| 48 |
|
| 49 |
if(/^\s*(use|require) +([\w:]+)/) { $modules{$2} = $1 } |
| 50 |
} |
| 51 |
|
| 52 |
close(FILE); |
| 53 |
} |
| 54 |
|
| 55 |
## Check if the modules are available |
| 56 |
for $module (keys %modules) { |
| 57 |
eval "$modules{$module} $module"; |
| 58 |
if($@) { |
| 59 |
if($modules{$module} eq 'use') { |
| 60 |
&fatal("Perl module $module is needed to use $program. \n") |
| 61 |
} else { |
| 62 |
&nonfatal("Perl module $module is not installed. \n", |
| 63 |
"Some fonctionalities of Html2Wml won't be available. \n") |
| 64 |
} |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
exit 0; |
| 69 |
|