++ed by:

1 non-PAUSE user.

Author image Bianka Martinovic


CGI::Application::Plugin::AnyCGI - Use your favourite CGI::* module with CGI::Application (instead of CGI.pm)


Version 0.02


In your CGI::Application-based module:

    use base 'CGI::Application';
    use CGI::Application::Plugin::AnyCGI;

    sub cgiapp_get_query() {
        my $self = shift;
        return CGI::Application::Plugin::AnyCGI->new(
            cgi_modules => [ qw/ CGI::Minimal CGI::Simple / ],
            ## any other options given here are passed to the  
            ## loaded CGI::* module


This module allows to use (nearly) any CGI.pm compatible CGI::* module with CGI::Application. Just give a list of your preferred modules by using the cgi_modules option with new(). The modules are checked in the same order they appear, so see it as a list of fallbacks.

If none of the modules in the cgi_modules list can be loaded, the Plugin silently loads CGI.pm as a final fallback.

If a method is called that is not provided by the module currently in use, it will be silently loaded from CGI.pm. This may eat up the "performance boost" you could have expected by using any other CGI::* module for your application, but on the other hand you don't have to worry about incompatibilities. ;)



This is the only (public) method C::A::P::AnyCGI provides. The one and only parameter C::A::P::AnyCGI uses is cgi_modules.

Calling new() without any further options

If no additional options are passed, C::A::P::AnyCGI returns an instance of itself, with the loaded module pushed at it's @ISA. (So, it acts as an empty subclass, just adding it's AUTOLOAD method to it's parent.)


        cgi_modules => [ qw/ CGI::Minimal CGI::Simple / ]

...returns an instance of CGI::Application::Plugin::AnyCGI, which inherits all methods of CGI::Minimal or CGI::Simple (or, as a final fallback, of CGI).

Calling new() with further options

If you pass any options, an instance of the loaded CGI::* module is created, passing all options (except cgi_modules) to the constructor. C::A::P::AnyCGI then imports it's AUTOLOAD method to the loaded module, returning the instance it created.


        cgi_modules => [ qw/ CGI::Simple / ],
        { 'foo'=>'1', 'bar'=>[2,3,4] }

...creates an instance of CGI::Simple, passing some params for initializing, and returns this instance to the caller.

Warning: As the different CGI::* modules don't take the same arguments to new, this may not work as expected, so it may be better not to use this option.


This module provides some internal debugging. Any debug messages go to STDOUT, so beware of enabling debugging when running in a web environment. (This will end up with "Internal Server Error"s in most cases.)

There are two ways to enable the debug mode:

In the module

Find line

    $CGI::Application::Plugin::AnyCGI::DEBUG = 0;

and set it to any "true" value. ("1", "TRUE", ... )

From outside the module

Add this line before calling new:

    $CGI::Application::Plugin::AnyCGI::DEBUG = 1;



While this plugin is made for use with CGI::Application, it should also work without it, so you should be able to use it with any other application you wish to be "CGI.pm independent".


Bianka Martinovic, <<mab at cpan.org> >


Please report any bugs or feature requests to bug-cgi-application-plugin-anycgi at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-Application-Plugin-AnyCGI. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc CGI::Application::Plugin::AnyCGI

You can also look for information at:



Copyright 2008 Bianka Martinovic, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.