tags:

views:

151

answers:

3

Is there something like <?php phpinfo(); ?> in Perl?

A: 

For clarification I have included the bash prompt symbol.

$ perl --version # This is what I would use
Josh K
it should be called from the script, not from the console. Thanks anyway!
elektronikLexikon
`my $info = \`perl --version\`; # You're welcome`
hlynur
`# 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.)`
jrockway
If you want to get the version, just use the $^V variable inside the program.
brian d foy
@jrockway: If that is the case you have bigger problems then a faulty script, the main one being high levels of dumbass present.
Josh K
@Josh: Nope, the main problem here is that you're doing the wrong thing. The 'perl' in your answer might not be the only one there is or the one you intend to use. When there's a much better answer, there's no sense defending such a poor one with a distraction about other problems. Just do it right from the start.
brian d foy
+3  A: 
use Config qw(myconfig);

print myconfig();

prints much of the information that perl -V does. You can also get individual elements of that information through the Config module.

cjm
+8  A: 

What information do you want to know? phpinfo apparently tells you almost everything:

Outputs a large amount of information about the current state of PHP. This includes information about PHP compilation options and extensions, the PHP version, server information and environment (if compiled as a module), the PHP environment, OS version information, paths, master and local values of configuration options, HTTP headers, and the PHP License.

You can get most of that somehow in Perl, but not all from the same place.

  • The Config module, which comes with Perl, has the compilation options for the interpreter
  • The Probe::Perl might give you a better interface
  • $^V has the version of the current interpreter (see perlvar)
  • %ENV has the environment (see perlvar)
  • You can use the Devel::CheckOS module to find out about the OS
  • Unless you are using mod_perl, your Perl CGI script will probably not have direct access to HTTP headers
brian d foy