<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Peter Edwards</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/peter_edwards/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/peter_edwards/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/peter_edwards//469</id>
    <updated>2011-06-08T11:55:13Z</updated>
    <subtitle>A blog about the Perl programming language</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>Installing Local Perl And Libraries On Mac Book Snow Leopard</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/peter_edwards/2011/06/installing-local-perl-and-libraries-on-mac-book-snow-leopard.html" />
    <id>tag:blogs.perl.org,2011:/users/peter_edwards//469.1836</id>

    <published>2011-06-08T09:02:32Z</published>
    <updated>2011-06-08T11:55:13Z</updated>

    <summary>I recently installed Perl 5.14 on a new Mac Book running Snow Leopard so I thought I&apos;d share my findings and experiences to save the next person doing this some time. I started off by doing a search on Google...</summary>
    <author>
        <name>Peter Edwards</name>
        <uri>http://perl.dragonstaff.co.uk</uri>
    </author>
    
    <category term="perlmacosxinstallinstalling" label="perl Mac OSX install installing" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/peter_edwards/">
        <![CDATA[<p>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.</p>

<p>I started off by doing a search on Google for "install perl mac".<br />
Hit number 1: Download Perl - www.perl.org <a href="http://www.perl.org/get.html">http://www.perl.org/get.html</a></p>

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

<p>It wasn't quite that easy so I've documented below exactly what I did. I've given feedback to Leo Laporte who looks after http://xrl.us/installperlosx and who should be updating the instructions on the perl.org page. At that point something like "curl -L http://xrl.us/installperlosx | bash" will work.</p>

<p>If you use a package manager directly, you'll find today (June 8th 2011) that macports offers you perl 5.12 and homebrew assumes you want to use your system perl, i.e. perl 5.10. The trouble with macports (or homebrew) is that they will fight over using /usr/local to store your local perl and you are better off installing it below your home directory using perlbrew.</p>

<p>Assuming you want perl 5.14, read on...</p>

<p><br />
<h2>A. Install local perl and libraries</h2></p>

<h3>1. Install Mac C compiler by installing XCode 4</h3>

<p>You can either install it from your install disks or buy it from the Mac online App Store.</p>

<p>There is a problem with XCode 4 that will stop PathTools building when installing perlbrew, see the problem described at<br />
  <a href="http://stackoverflow.com/questions/5256397/python-easy-install-fails-with-assembler-for-architecture-ppc-not-installed-on">http://stackoverflow.com/questions/5256397/python-easy-install-fails-with-assembler-for-architecture-ppc-not-installed-on</a></p>

<p>To fix:<br />
$ echo 'export ARCHFLAGS="-arch i386"' >> ~/.bash_login<br />
$ export ARCHFLAGS="-arch i386"</p>

<h3>2. Bootstrap local::lib for Perl local library support</h3>

<p>download local::lib from <a href="http://search.cpan.org/CPAN/authors/id/A/AP/APEIRON/local-lib-1.008004.tar.gz">http://search.cpan.org/CPAN/authors/id/A/AP/APEIRON/local-lib-1.008004.tar.gz</a><br />
$ tar xfz local-lib-1.008004.tar.gz<br />
$ cd local-lib-1.008004<br />
$ perl Makefile.PL --bootstrap=~/perl_local1<br />
$ make test<br />
$ make install</p>

<p>$ echo 'eval $(perl -I$HOME/perl_local1/lib/perl5 -Mlocal::lib=$HOME/perl_local1' >> ~/.bash_login</p>

<p>set up environment for local build<br />
$ . ~/.bash_login</p>

<p>That has you configured to install all your CPAN modules below ~/perl_local1.<br />
Later if you want to have a different local::lib for different perl versions or different apps you can easily enough change your setup like above. </p>

<h3>3. Install App::cpanminus  for easier CPAN module installation</h3>

<p>$ cpan App::cpanminus</p>

<h3>4. Install App::perlbrew for easier local Perl version binary building</h3>

<p>$ cpanm App::perlbrew<br />
$ perlbrew init</p>

<p>$ echo 'source ~/perl5/perlbrew/etc/bashrc' >> ~/.bash_login<br />
$ source ~/perl5/perlbrew/etc/bashrc</p>

<p>$ perlbrew available<br />
  perl-5.14.0<br />
  perl-5.12.3<br />
  perl-5.10.1<br />
  perl-5.8.9<br />
  perl-5.6.2<br />
  perl5.005_04<br />
  perl5.004_05<br />
  perl5.003_07</p>

<h3>5. Install a local perl 5.14 and start using it</h3>

<p>$ perlbrew install perl-5.14.0<br />
(wait 30 minutes)</p>

<p>$ perlbrew use perl-5.14.0<br />
$ perl -v<br />
(should report that you are running perl 5.14)</p>

<p><br />
<h2>B. Install "homebrew" package manager</h2></p>

<p>1. Install XCode 4 (already done above)</p>

<p>2. Install Java developer update</p>

<p><a href="http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=20719">http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=20719</a></p>

<p>3. Install homebrew</p>

<p>$ ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"<br />
$ brew install git<br />
$ brew update</p>

<p>Now you can install or build packages using the "brew" command.</p>

<p>An alternative is macports <a href="http://www.macports.org">http://www.macports.org</a></p>]]>
        
    </content>
</entry>

<entry>
    <title>Colorized perl code snippets on ANSI terminals</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/peter_edwards/2010/08/colorized-perl-code-snippets-on-ansi-terminals.html" />
    <id>tag:blogs.perl.org,2010:/users/peter_edwards//469.864</id>

    <published>2010-08-09T18:13:57Z</published>
    <updated>2010-08-09T18:38:14Z</updated>

    <summary>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...</summary>
    <author>
        <name>Peter Edwards</name>
        <uri>http://perl.dragonstaff.co.uk</uri>
    </author>
    
    <category term="perlcoloransikate" label="Perl color ANSI Kate" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/peter_edwards/">
        <![CDATA[<p>Ever wanted to do a quick diff on some perl code and see it colored like in in vim ?</p>

<p>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:</p>

<pre><code>#!/usr/bin/perl
# hilite.pl - perl code colorizer on an ANSI terminal (xterm / putty session)
# place this script in your path and make executable, e.g.
#   $ cp hilite.pl ~/bin/hilite
#   $ chmod 755 ~/bin/hilite
# then run it to colorize text output that contains perl, e.g.
#   $ svn diff /some/path/MyModule.pm | 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 =&gt; 'Perl',
    substitutions =&gt; {},
    format_table =&gt; {
        Alert =&gt; [RED, RESET],
        BaseN =&gt; [RED, RESET],
        BString =&gt; [YELLOW, RESET],
        Char =&gt; [YELLOW, RESET],
        Comment =&gt; [CYAN, RESET],
        DataType =&gt; [GREEN, RESET],
        DecVal =&gt; [RED, RESET],
        Error =&gt; [RED, RESET],
        Float =&gt; [BRIGHT_RED, RESET],
        Function =&gt; [MAGENTA, RESET],
        IString =&gt; [MAGENTA, RESET],
        Keyword =&gt; [YELLOW, RESET],
        Normal =&gt; ["", ""],
        Operator =&gt; [BRIGHT_GREEN, RESET],
        Others =&gt; [MAGENTA, RESET],
        RegionMarker =&gt; [ON_GREEN, RESET],
        Reserved =&gt; [BLACK ON_BLUE, RESET],
        String =&gt; [MAGENTA, RESET],
        Variable =&gt; [BRIGHT_GREEN, RESET],
        Warning =&gt; [RED, RESET],
    },
);

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

while ( my $line = &lt;$fh&gt; ) {
    print $hl-&gt;highlightText($line);
};
</code></pre>
]]>
        

    </content>
</entry>

</feed>
