A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Mojolicious basics

How to do common stuff.

Run an app:

MOJO_USERAGENT_DEBUG=1 perl -I lib ~/path/to/morbo --verbose --watch lib --watch local bin/app.pl

View existing routes:

perl -I lib bin/app.pl routes

Find the code that defines the routes:

grep -r '$r->get' .
grep -r '$r->post' .

Install database:

perl -I lib bin/app.pl dbic_migration --action=install

Write a script that uses the app config, etc:

See Mojolicious::Command

Debug Test::Mojo:

print $t->tx->res->body; # See also guide to debugging

Catch unexpected exceptions:

Dump out 2nd-level routes:
my @routes = sort map { $_->to_string } map { @{ $_->children } }
    grep { $_->name eq 'distro' || $_->name eq 'candidates' }
    @{ $t->app->routes->children };

Best Data::Dumper configuration for debugging Perl

This:

  local $Data::Dumper::Indent=0;
  local $Data::Dumper::Varname='';
  local $Data::Dumper::Terse=1;
  local $Data::Dumper::Pair='=>';
  local $Data::Dumper::Sortkeys=1;
  local $Data::Dumper::Quotekeys=0;

(source)

Or:

use Mojo::Util 'dumper';