July 2010 Archives

The mod_perl debugger you've always wanted

To use the nice mod_perl debugger you've always wanted:

To connect the two and start up your apache with no fuss:

# httpd.conf
<Perl>
    use Enbugger;

    # Send the debugger to your waiting terminal server but disable readline
    # because I haven't figured that part out yet.
    $ENV{PERLDB_OPTS} = 'RemotePort=localhost:53505';
    $ENV{PERL_RL}     = 0;

    Enbugger->load_debugger;
</Perl>

This is all flexible so you can have an ordinary forking mod_perl and don't need to start it any strange way. If you're adventurous, you could inject this right into your running mod_perl by using that snippet somewhere in your application. If you're desperate and have a problem in production and want a debugger there, check out http://bit.ly/bGqCOT to add it at runtime from the outside.

I'm still playing with the proper settings for $ENV{PERL_RL}. I used 'o=0' yesterday and it seemed ok but maybe ought to be 0 instead. Also, I think possibly the terminal servers want more work.

Unicode in Perl, FTW (Я очень рад, ведь я, наконец, возвращаюсь домой)

Found on my hard drive. I love that it's source code that's literally in UTF-8 and it all just looks "right" or whatever that Russian says.

use utf8;
use Encode 'encode';
print encode("ascii", 'Я очень рад, ведь я, наконец, возвращаюсь домой', sub{ sprintf "", shift });;

BTW:

="h…

Under the covers of perldoc

Sometime last year I had to go find out what happens under the covers when a user types a command like "perldoc strict." Here's the trace of which commands call which other commands. It's all in good fun.

I'd used strace to get a process-by-process trace of what happened to just the execve and clone syscalls.

strace -e trace=clone,execve -ff perldoc strict

And the eventual picture resolved:

/usr/bin/perldoc strict
    /home/josh/bin/stty -a
    /home/josh/src/git-utils/stty -a
    /home/josh/bin/stty -a
    /home/josh/src/git-utils/stty -a
    /usr/local/sbin/stty -a
    /usr/local/bin/stty -a
    /usr/sbin/stty -a
    /usr/bin/stty -a
    /sbin/stty -a
    /bin/stty -a
    /bin/sh -c "/usr/bin/pod2man --lax /usr/share/perl/5.10/strict.pod | nroff -man -rLL=229n"
        /usr/bin/pod2man --lax /usr/share/perl/5.10/strict.pod
        /usr/bin/nroff -man -rLL=229n
            /usr/bin/locale charmap
            /usr/bin/groff -mtty-char -Tutf8 -man -rLL=229n
                /usr/bin/troff -mtty-char -man -rLL=229n -Tutf8
                /usr/bin/grotty
    /bin/sh -c "/usr/bin/sensible-pager \"/tmp/eHhH5a9wPU\""
        /usr/bin/sensible-pager /tmp/eHhH5a9wPU
            /usr/bin/pager /tmp/eHhH5a9wPU
                /bin/sh -c "/bin/bash -c \\ /usr/bin/lesspipe\\ /tmp/eHhH5a9wPU"
                    /bin/bash -c " /usr/bin/lesspipe /tmp/eHhH5a9wPU"
                    /usr/bin/lesspipe /tmp/eHhH5a9wPU
                        /usr/bin/basename /usr/bin/lesspipe
                            /usr/bin/tr "[:upper:]" "[:lower:]"

About Josh ben Jore

user-pic