1 |
package Pod::HtmlPsPdf::RunTime; |
2 |
|
3 |
use strict; |
4 |
|
5 |
%Pod::HtmlPsPdf::RunTime::options = (); |
6 |
|
7 |
# check whether we have a Storable avalable |
8 |
eval {require Storable;}; |
9 |
my $Storable_exists = $@ ? 0 : 1; |
10 |
|
11 |
######################## |
12 |
sub set_runtime_options{ |
13 |
%Pod::HtmlPsPdf::RunTime::options = %{+shift}; |
14 |
} # end of sub set_runtime_options |
15 |
|
16 |
# returns 1 if true, 0 -- otherwise |
17 |
####################### |
18 |
sub has_storable_module{ |
19 |
|
20 |
# ps2html is bundled, so we can create PS |
21 |
return $Storable_exists; |
22 |
|
23 |
} # end of sub has_storable_module |
24 |
|
25 |
# returns 1 if true, 0 -- otherwise |
26 |
################# |
27 |
sub can_create_ps{ |
28 |
|
29 |
# ps2html is bundled, so we can always create PS |
30 |
return 1; |
31 |
|
32 |
# if you unbundle it make sure you write here a code similar to |
33 |
# can_create_pdf() |
34 |
|
35 |
} # end of sub can_create_ps |
36 |
|
37 |
# returns 1 if true, 0 -- otherwise |
38 |
################# |
39 |
sub can_create_pdf{ |
40 |
|
41 |
# check whether ps2pdf exists |
42 |
my $ps2pdf_exists = which( 'ps2pdf' ); |
43 |
|
44 |
print(qq{It seems that you do not have ps2pdf installed! You have |
45 |
to install it if you want to generate the PDF file |
46 |
}), |
47 |
return 0 |
48 |
unless $ps2pdf_exists; |
49 |
return 1; |
50 |
|
51 |
} # end of sub can_create_pdf |
52 |
|
53 |
sub which { |
54 |
my $cmd = shift; |
55 |
|
56 |
foreach my $dir (split( ':', $ENV{PATH})) { |
57 |
return "$dir/$cmd" if -x "$dir/$cmd"; |
58 |
} |
59 |
|
60 |
return; |
61 |
} |
62 |
|
63 |
|
64 |
|
65 |
|
66 |
1; |
67 |
__END__ |