Web::Detect - Detect if program is running under some web environment
This document describes version 0.05 of Web::Detect (from Perl distribution Web-Detect), released on 2015-01-03.
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.
Please visit the project's homepage at https://metacpan.org/release/Web-Detect.
Source repository is at https://github.com/sharyanto/perl-Web-Detect.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Web-Detect
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2015 by perlancar@cpan.org.
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.