Filewatcher File Search File Search
Content Search
» » » » » » CGI-Inspect-0.5.tar.gz » Content »
pkg://CGI-Inspect-0.5.tar.gz:158892/CGI-Inspect-0.5/  info  downloads


    CGI::Inspect - Inspect and debug CGI apps with an in-browser UI

      use CGI::Inspect; # This exports inspect()

      print "Content-type: text/html\n\n";

      my $food = "toast";

      for my $i (1..10) {
        print "$i cookies for me to eat...<br>";
        inspect() if $i == 5; # be sure to edit $toast :)

      print "I also like $food!";

    This class is a drop-in web based inspector for plain CGI (or CGI-based)
    applications. Include the library, and then call inspect(). In your
    server error logs you'll see something like "Please connect to
    localhost:8080". When you do, you'll be greeted with an inspection UI
    which includes a stack trace, REPL, and other goodies.

    To work it's magic this modules uses Continuity, Devel::LexAlias,
    Devel::StackTrace::WithLexicals, and their prerequisites (such as
    PadWalker). Remember that you can always install such things locally for
    debugging -- no need to install them systemwide (in case you are afraid
    of the power that they provide).

    This starts the Continuity server and inspector on the configured port
    (defaulting to 8080). You can pass it parameters which it will then pass
    on to CGI::Inspect->new. The most useful one is probably port:

      inspect( port => 12345 );

    Another useful parameter is plugins. The default is:

        plugins => [qw( BasicLook Exit REPL CallStack )]

    CGI::Inspect comes with a few plugins by default:

    *   REPL - A simple Read-Eval-Print prompt

    *   StackTrace - A pretty stack trace (with lexical editing!)

    *   Exit - Stop inspecting

  Creating Plugins
    Plugins are easy to create! They are really just subroutines that return
    a string for what they want printed. All of the built-in plugins actuall
    inherti from CGI::Inspect::Plugin, which just provides some convenience
    methods. The main CGI::Inspect module will create an instance of your
    plugin with Plugin->new, and then will execute it with $plugin->process.

    Plugins can, however, make use of Continuity, including utilizing
    callbacks. Here is the complete source to the 'Exit' plugin, as a fairly
    simple example.

      package CGI::Inspect::Plugin::Exit;

      use strict;
      use base 'CGI::Inspect::Plugin';

      sub process {
        my ($self) = @_;
        my $exit_link = $self->request->callback_link(
          Exit => sub {
            $self->manager->{do_exit} = 1;
        my $output = qq{
          <div class=dialog title="Exit">
        return $output;


    For now, read the source of the default plugins for further ideas. And
    of course email the author if you have any questions or ideas!

    These methods are all internal. All you have to do is call inspect().

    Create a new monitor object.

    Load plugins and start inspecting!

    Initialize the Continuity server, and begin the run loop.

    Display the current page, based on $self->{content}

    Returns the current request obj

    Load all of our plugins.

    This is executed as the entrypoint for inspector sessions.


      Brock Wilcox <> -

      Copyright (c) 2008-2009 Brock Wilcox <>. All rights
      reserved.  This program is free software; you can redistribute it and/or
      modify it under the same terms as Perl itself.

Results 1 - 1 of 1
Help - FTP Sites List - Software Dir.
Search over 15 billion files
© 1997-2017