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

Perl tools

Perl Needs Better Tools

IDEs

  • Padre is free, supposedly it knows more about Perl internals than other IDEs.
    • Syntax highlighting: View|Style|Evening
    • Current line highlight colour: Tools|Preferences|Appearance|Editor Current Line Background Colour
  • Eclipse is free but, seems very heavyweight. Extensible with plugins (Version control, etc. See EPIC for Perl)
  • Komodo is paid, but is explicitly designed for Perl. It has a remote debugging feature, which works! You have to install a script on the remote server, and have access to the remote fileystem to display the source code.
  • NetBeans is free
  • IntelliJ IDEA is paid, and has no Perl plugin
Text editors
  • vim - I use this a lot. It has keyword lookup (if you can configure it), a powerful but difficult-to-use scripting language, and tabs, but no debugging support. Lots of scripts/add-ons available.
  • Emacs - some of my colleagues use it, can be very powerful with add-ons/perl modules
  • UltraEdit
  • Textpad - Windows only. Nice to use, has plugins
  • Sublime - A nice text editor
Further reading

  • Why should I use an IDE?
  • TODO: [an article on coding horror or somewhere "what would a good IDE look like?"] where is it?

Catch runaway processes on Mac

#!/bin/sh

# kill runaway processes at 100% CPU usage (Mac OSX)
export PNAME=$1
if [[ ! $PNAME ]]
then
    echo "usage: runaways.sh [process name]"
    exit
fi

export PPERCENT='100.0'
SECONDS_TO_TEST=20
THRESHOLD=15

SECONDS_RUNAWAY=$(top -l $SECONDS_TO_TEST | perl -lne'BEGIN{$c=0};/$ENV{PNAME}\s+$ENV{PPERCENT}\%/ && do { $c++ };END{print$c}');
if [[ $SECONDS_RUNAWAY -gt $THRESHOLD ]]
then
    echo "killing $PNAME at $PPERCENT"%...
    PID=$(top -o cpu -l 2 | perl -lne'/$ENV{PNAME}\s+$ENV{PPERCENT}\%/ && print $1')
    if [[ $PID ]]
    then
        echo "Killing $PNAME"
        kill -9 $PID
    else
        echo "$PNAME does not exceed the threshold for a runaway"
    fi
else
    echo "$PNAME is not runaway"
fi