1package HTML::Perlinfo;
2BEGIN { %HTML::Perlinfo::Seen = %INC }
3
4use strict;
5use warnings;
6use Carp ();
7
8use HTML::Perlinfo::Apache;
9use HTML::Perlinfo::Modules;
10use HTML::Perlinfo::Common;
11
12use base qw(Exporter HTML::Perlinfo::Base);
13our @EXPORT = qw(perlinfo);
14
15our $VERSION = '1.69';
16
17sub perlinfo {
18  my ($opt) = @_;
19  $opt = 'INFO_ALL' unless $opt;
20
21  error_msg("Invalid perlinfo() parameter: @_")
22  if (($opt !~ /^INFO_(?:ALL|GENERAL|CONFIG|VARIABLES|APACHE|MODULES|LICENSE|LOADED)$/) || @_ > 1);
23
24  $opt = lc $opt;
25  my $p = HTML::Perlinfo->new();
26  $p->$opt;
27
28}
29foreach my $key (%HTML::Perlinfo::Seen) {
30    $INC{$key} = $HTML::Perlinfo::Seen{$key} unless exists $INC{$key};
31}
321;
33__END__
34=pod
35
36=head1 NAME
37
38HTML::Perlinfo - Display a lot of Perl information in HTML format
39
40=head1 SYNOPSIS
41
42	use HTML::Perlinfo;
43
44	perlinfo();
45
46
47	use HTML::Perlinfo;
48	use CGI qw(header);
49
50	$|++;
51
52	print header;
53	perlinfo(INFO_MODULES);
54
55=head1 DESCRIPTION
56
57This module outputs a large amount of information about your Perl installation in HTML. So far, this includes information about Perl compilation options, the Perl version, server information and environment, HTTP headers, OS version information, Perl modules, and more.
58
59HTML::Perlinfo is aimed at Web developers, but almost anyone using Perl may find it useful. It is a valuable debugging tool as it contains all EGPCS (Environment, GET, POST, Cookie, Server) data. It will also work under taint mode.
60
61The output may be customized by passing one of the following options.
62
63=head1 OPTIONS
64
65There are 8 options to pass to the perlinfo funtion. All of these options are also object methods. The key difference is their case: Captilize the option name when passing it to the function and use only lower-case letters when using the object-oriented approach.
66
67=over
68
69=item INFO_GENERAL
70
71The Perl version, build date, and more.
72
73=item INFO_VARIABLES
74
75Shows all predefined variables from EGPCS (Environment, GET, POST, Cookie, Server).
76
77=item INFO_CONFIG
78
79All configuration values from config_sh. INFO_ALL shows only some values.
80
81=item INFO_APACHE
82
83Apache HTTP server information, including mod_perl information.
84
85=item INFO_MODULES
86
87All installed modules, their version number and description. INFO_ALL shows only core modules.
88Please also see L<HTML::Perlinfo::Modules>.
89
90=item INFO_LOADED
91
92Post-execution dump of loaded modules (plus INFO_VARIABLES). INFO_ALL shows only core modules. Please also see L<HTML::Perlinfo::Loaded>.
93
94=item INFO_LICENSE
95
96Perl license information.
97
98=item INFO_ALL
99
100Shows all of the above defaults. This is the default value.
101
102=back
103
104=head1 PROGRAMMING STYLE
105
106There are two styles of programming with Perlinfo.pm, a function-oriented style and an object-oriented style.
107
108Function-oriented style:
109
110	# Show all information, defaults to INFO_ALL
111	perlinfo();
112
113	# Show only module information. This shows all installed modules.
114	perlinfo(INFO_MODULES);
115
116Object-oriented style:
117
118	$p = new HTML::Perlinfo;
119	$p->info_all;
120
121	# You can also set the CSS values in the constructor!
122    	$p = HTML::Perlinfo->new(
123		bg_image  => 'http://i104.photobucket.com/albums/m176/perlinfo/camel.gif',
124		bg_repeat => 'yes-repeat'
125	);
126	$p->info_all;
127
128More examples ...
129
130	# This is wrong (no capitals)
131	$p->INFO_MODULES;
132
133	# But this is correct
134	perlinfo(INFO_MODULES);
135
136	# Ditto
137	$p->info_modules;
138
139=head1 CUSTOMIZING THE HTML
140
141You can capture the HTML output and manipulate it or you can alter CSS elements with object attributes.
142
143For further details and examples, please see the L<HTML documentation|HTML::Perlinfo::HTML> in the HTML::Perlinfo distribution.
144
145=head1 SECURITY
146
147Displaying detailed server information on the internet is not a good idea and HTML::Perlinfo reveals a lot of information about the local environment. While restricting what system users can publish online is wise, you can also hinder them from using the module by installing it outside of the usual module directories (see perldoc -q lib). Of course, preventing users from installing the module in their own home directories is another matter entirely.
148
149=head1 REQUIREMENTS
150
151HTML::Perlinfo does not require any non-core modules. There are no requirements, except Perl version 5.6 and above.
152
153=head1 NOTES
154
1551. Print the content-type header first if you are using the module in a CGI setting. (mod_perl handles this for you automatically.) If you do not print the header, you will produce an internal server error. Of course, you can forgo a Web server entirely and use the module at the command-line. Please see the L<perlinfo> tool included in this distribution.
156
1572. If the HTML takes too long to load in the browser, then you can try flushing the output buffer. By flushing the buffer, the HTML will start appearing immediately.
158
159INFO_APACHE relies soley on environment variables. If you don't use Apache, there is nothing to worry about. You do not need to turn INFO_APACHE off or anything. The section will simply not appear. Any Web server information will still be in the environment variables, unless you configure your server to not report information.
160
161INFO_VARIABLES did not work correctly until version 1.52.
162
163INFO_LOADED is the only option whose output cannot be assigned to a scalar.
164
165Since the module outputs HTML, you may want to use it in a CGI script, but you do not have to. Of course, some information, like HTTP headers, would not be available if you use the module at the command-line. If you decide to use this module in a CGI script, B<make sure you print out the content-type header beforehand>. For example:
166
167	use HTML::Perlinfo;
168
169	print "Content-type: text/html\n\n";
170	perlinfo();
171
172I prefer to use the header function from the CGI module:
173
174	use HTML::Perlinfo;
175	use CGI qw(header);
176
177	print header;
178	perlinfo();
179
180HTML::Perlinfo stopped printing the header automatically as of version 1.43.
181
182By flushing the output buffer, you can make the HTML appear immediately. If your program is running slow, then you can try flushing the buffer.
183
184In this example, I am flushing the buffer because I know that there will be a lot of modules:
185
186	use HTML::Perlinfo;
187	use CGI qw(header);
188
189	$|++;
190
191	print header;
192	perlinfo(INFO_MODULES);
193
194Some might notice that HTML::Perlinfo shares the look and feel of the PHP function phpinfo. It was originally inspired by that function and was first released in 2004 as PHP::Perlinfo, which is no longer available on CPAN.
195
196=head1 BUGS
197
198If you'd like to report an issue you can use github's
199L<issue tracker|https://github.com/mixedconnections/HTML-Perlinfo/issues>.
200
201=head1 SEE ALSO
202
203L<Config>. You can also use "perl -V" to see a configuration summary at the command-line.
204
205L<CGI::Carp::Fatals>, L<Apache::Status>, L<App::Info>, L<Probe::Perl>, L<Module::CoreList>, L<Module::Info>, among others.
206
207Also included in the Perlinfo distribution: L<perlinfo>, L<HTML::Perlinfo::Loaded>, L<HTML::Perlinfo::Modules>
208
209=head1 AUTHOR
210
211Mike Accardo <accardo@cpan.org>
212
213=head1 COPYRIGHT
214
215   Copyright (c) 2004-9, Mike Accardo. All Rights Reserved.
216 This module is free software. It may be used, redistributed
217and/or modified under the terms of the Perl Artistic License.
218
219=cut
220
221