Installing Local Perl And Libraries On Mac Book Snow Leopard

I recently installed Perl 5.14 on a new Mac Book running Snow Leopard so I thought I'd share my findings and experiences to save the next person doing this some time.

I started off by doing a search on Google for "install perl mac".
Hit number 1: Download Perl -

That suggests you have a perl already installed, which is currently perl 5.10, or you can use App::Perlbrew.

It wasn't quite that easy so I've documented below exactly what I did. I've given feedback to Leo Laporte who l…

Colorized perl code snippets on ANSI terminals

Ever wanted to do a quick diff on some perl code and see it colored like in in vim ?

Fortunately, the Kate editor has a good colorizer and Gabor Szabo ported it to Perl. We can join that up with Term::ANSIColor to create a filter program to colorize perl code snippets on the fly:

# - perl code colorizer on an ANSI terminal (xterm / putty session)
# place this script in your path and make executable, e.g.
#   $ cp ~/bin/hilite
#   $ chmod 755 ~/bin/hilite
# then run it to colorize text output that contains perl, e.g.
#   $ svn diff /some/path/ | hilite
# and you get syntax colored text

use strict;
use warnings;
use utf8; # ار
use open ':utf8';

use Syntax::Highlight::Engine::Kate;
use Term::ANSIColor qw(:constants);
use IO::File;

my $hl = new Syntax::Highlight::Engine::Kate(
    language => 'Perl',
    substitutions => {},
    format_table => {
        Alert => [RED, RESET],
        BaseN => [RED, RESET],
        BString => [YELLOW, RESET],
        Char => [YELLOW, RESET],
        Comment => [CYAN, RESET],
        DataType => [GREEN, RESET],
        DecVal => [RED, RESET],
        Error => [RED, RESET],
        Float => [BRIGHT_RED, RESET],
        Function => [MAGENTA, RESET],
        IString => [MAGENTA, RESET],
        Keyword => [YELLOW, RESET],
        Normal => ["", ""],
        Operator => [BRIGHT_GREEN, RESET],
        Others => [MAGENTA, RESET],
        RegionMarker => [ON_GREEN, RESET],
        Reserved => [BLACK ON_BLUE, RESET],
        String => [MAGENTA, RESET],
        Variable => [BRIGHT_GREEN, RESET],
        Warning => [RED, RESET],

my $fh;
my $file = shift @ARGV;
if ( !$file || $file eq '-' ) {
    binmode STDIN;
    $fh = \*STDIN;
else {
    $fh = IO::File->new($file)
        || die "Cannot open file: $file: $!";

while ( my $line = <$fh> ) {
    print $hl->highlightText($line);