September 2023 Archives

CGI::Tiny & Dispatch::Fu - nearly a perfect match

CGI::Tiny is a very nice, Perlish way to construct CGI scripts these days. It is perfectly suited as a replacement to and is quite at home in a shared hosting environment.

Here's the example from the POD [1] on metacpan:

    use CGI::Tiny;
    cgi {
      my $cgi = $_;
      # set up error handling on $cgi
      # inspect request data via $cgi
      # set response headers if needed via $cgi
      # render response with $cgi->render or $cgi->render_chunk

I recently coupled this with my new module Dispatch::Fu [2], and it worked exceedingly well. It is a darn pleasure to consider from a distance, if I do say so myself:

    use CGI::Tiny;
    use Dispatch::Fu;

    cgi {
      my $cgi = $_;
      dispatch {
        my $cgi = shift;
        if (defined $cgi->param('fribble')) {
          return 'fribble';
        return 'default';
      on fribble => sub { do_fribble($cgi) },
      on default => sub { do_default($cgi) }; #<~semicolon

    sub fribble {
      my $cgi = shift;
      # application/json;charset=UTF-8
      $cgi->render(json         => { msg => 'fribble says hi' });

    sub default {
      # text/html;charset=$charset
      $cgi = $cgi->render(html  => '<html><head>...');

As you may be able to see, this code is able to scale very nicely as different display needs are added.





[3] Syntax highlighting done by converting Perl to HTML at

This article originally appeared at gopher://

I just discovered

I don't really keep up with online resources, and I to be (like perl) a nice and stable home. I've watched resources come and go - I've lost untold content in the process (geocities, myspace, LtU, hello??).

I recently discovered because of a nice benchmarking article published by a long standing community member:

Benchmarking Perl Core Class in v5.38 By John Napiorkowski

So I guess this is like some kind of substack for developer blogging? I only recently discovered that resource also.

About Brett Estrade

user-pic PAUSE Id: OODLER