Web::Detect - Detect if program is running under some web environment
version 0.04
use Web::Detect qw(detect_web detect_web_fast); use IO::Interactive::Tiny (); if (Web::Detect::detect_web_fast()) { # do HTML } else { # do CLI if (IO::Interactive::Tiny::is_interactive()) { # prompt/ANSI/etc } else { # do not prompt/plain text/etc } }
Knowing if you are under a web environment or not is very handy.
For example, often you need to decide whether to output HTML or plaintext.
Functions are exportable but are not exported by default.
Return false if not detected running under any web environment.
Return a hash otherwise.
These keys exists if it is detected that we are running under the given environment and the value is suitable as a boolean (always true).
mod_perl
plack
pangea
cpanel
http://cpanel.net
catalyst
dancer
mojo
FCGI.pm
IIS
cgi
General CGI
general
Value can be 1 if it was detected during the first general check, 2 if it was detected during the second general check, and 3 if it was detected under both.
Additionally, psgi is also true if we know its a PSGI environment.
psgi
Same as detect_web() but return HASHREF upon first successful check instead of trying all heuristics.
Make heuristics even better!
More links/description to each HASHREF key.
Never enough tests.
Steven Haryanto <stevenharyanto@gmail.com>
This software is copyright (c) 2013 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Web::Detect, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Web::Detect
CPAN shell
perl -MCPAN -e shell install Web::Detect
For more information on module installation, please visit the detailed CPAN module installation guide.