【发布时间】:2011-04-14 00:33:53
【问题描述】:
Perl 中有类似<?php phpinfo(); ?> 的东西吗?
【问题讨论】:
-
请注意!你不需要;。 ?> 添加一个;。所以 或
Perl 中有类似<?php phpinfo(); ?> 的东西吗?
【问题讨论】:
为了清楚起见,我已经包含了 bash 提示符。
$ perl --version # This is what I would use
【讨论】:
# oops, the perl in the path is not the one running this script. you were running suid and "perl" was actually a shell script placed into $PATH that deletes everything on the system. (at least your script got deleted too.)
use Config qw(myconfig);
print myconfig();
打印perl -V 所做的大部分信息。您还可以通过Config 模块获取该信息的各个元素。
【讨论】:
你想知道什么信息? phpinfo 显然告诉你几乎所有事情:
输出大量关于 PHP 当前状态的信息。这包括有关 PHP 编译选项和扩展、PHP 版本、服务器信息和环境(如果编译为模块)、PHP 环境、操作系统版本信息、路径、配置选项的主值和本地值、HTTP 标头和 PHP许可。
您可以在 Perl 中以某种方式获得大部分内容,但不能全部来自同一个地方。
Config 模块具有解释器的编译选项$^V 拥有当前解释器的版本(见perlvar)%ENV 有环境(见perlvar)【讨论】:
只是为了添加,不要忘记在文件中添加 Perl bin 路径。
我使用的示例脚本如下:
确保以下行是文件中的第一行:
#!/usr/bin/perl
或者对于 windows,可能类似于(取决于您的环境):
#!C:/wamp/bin/Perl64/bin/perl.exe
片段:
#!/usr/bin/perl
# test.cgi by Bill Weinman [http://bw.org/]
# Copyright 1995-2008 The BearHeart Group, LLC
# Free Software: Use and distribution under the same terms as perl.
use strict;
use warnings;
use CGI;
print foreach (
"Content-Type: text/plain\n\n",
"BW Test version 5.0\n",
"Copyright 1995-2008 The BearHeart Group, LLC\n\n",
"Versions:\n=================\n",
"perl: $]\n",
"CGI: $CGI::VERSION\n"
);
my $q = CGI::Vars();
print "\nCGI Values:\n=================\n";
foreach my $k ( sort keys %$q ) {
print "$k [$q->{$k}]\n";
}
print "\nEnvironment Variables:\n=================\n";
foreach my $k ( sort keys %ENV ) {
print "$k [$ENV{$k}]\n";
}
【讨论】: