View on
MacGyveR > CGI-Mungo-1.6 > CGI::Mungo



Annotate this POD

View/Report Bugs
Module Version: 1.6   Source   Latest Release: CGI-Mungo-1.9


CGI::Mungo - Very simple CGI web framework


        use CGI::Mungo;
        my $options = {
                'responsePlugin' => 'Some::Class'
        my $m = CGI::Mungo->new($options);
        my $actions = {
                "default" => sub{},     #do nothing
                "list" => \&someSub(),  #use a named sub
                "add" => sub{my $var = 1;}      #use an anonymous sub
        $m->run();      #do this thing!


All action subs are passed a CGI::Mungo object as the only parameter, from this you should be able to reach everything you need.



        my $options = {
                'responsePlugin' => 'Some::Class',
                'checkReferer' => 0,
                'sessionClass' => 'Some::Class',
                'requestClass' => 'Some::Class'
        my $m = CGI::Mungo->new($options);

Constructor, requires a hash references to be passed as the only argument. This hash reference contains any general options for the framework.


        my $response = $m->getResponse();

Returns an instance of the response plugin object, previously defined in the constructor options. See CGI::Mungo::Response for more details.


        my $session = $m->getSession();

Returns an instance of the CGI::Mungo::Session object.


        my $request = $m->getRequest();

Returns an instance of the CGI::Mungo::Request object.


        my %actions = (
                'default' => \&showMenu().
                'list' => \%showList() 

Sets the actions of the web application using a hash reference. The names of the keys in the hash reference will match the value of the given "action" form field from the current request. Hash reference values can be references to subs or annoymous subs.

An action of 'default' can be used when a visitor does not request a specific action.


        my $action = $m->getAction();

Returns the curent action that the web application is performing. This is the current value of the "action" request form field.



This methood is required for the web application to deal with the current request. It should be called after any setup is done.


The following list gives a summary of each Mungo configuration options.


A scalar string consisting of the response class to use.

See CGI::Mungo::Response::Base for details on how to create your own response class, or a list of response classes provided in this package.


Flag to indicate if referer checking should be performed. When enabled an error will raised when the referer is not present or does not contain the server's hostname.

This option is enabled by default.


A scalar string consisting of the session class to use. Useful if you want to change the way session are stored.

Defaults to ref($self)::Session


A scalar string consisting of the request class to use. Useful if you want to change the way requests are handled.

Defaults to ref($self)::Request

Notes ^

To change the session prefix characters use the following code at the top of your script:

        $CGI::Mungo::Session::prefix = "ABC";

To change the session file save path use the following code at the top of your script:

        $CGI::Mungo::Session::path = "/var/tmp";

Author ^

MacGyveR <>

Development questions, bug reports, and patches are welcome to the above address

Copyright ^

Copyright (c) 2012 MacGyveR. All rights reserved.

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

syntax highlighting: