<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Laufeyjarson writes...</title>
	<atom:link href="http://blog.laufeyjarson.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.laufeyjarson.com</link>
	<description>... notes, thoughts, rants, and randomness.</description>
	<lastBuildDate>Sat, 04 Feb 2012 04:56:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Perforce auth-check trigger for Unix passwd file</title>
		<link>http://blog.laufeyjarson.com/2012/02/perforce-auth-check-trigger-for-unix-passwd-file/</link>
		<comments>http://blog.laufeyjarson.com/2012/02/perforce-auth-check-trigger-for-unix-passwd-file/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 04:56:04 +0000</pubDate>
		<dc:creator>Laufeyjarson</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[perl perforce]]></category>

		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=152</guid>
		<description><![CDATA[I just installed Perforce (what a hassle!) and discovered that it won&#8217;t authenticate to the local Unix accounts out of the box.  The nice folks at Perforce let you call an external trigger, and provide a complex sample that will handle talking to Active Directory, but don&#8217;t have one do handle ordinary Unix passwd access. [...]]]></description>
			<content:encoded><![CDATA[<p>I just installed Perforce (what a hassle!) and discovered that it won&#8217;t authenticate to the local Unix accounts out of the box.  The nice folks at Perforce let you call an external trigger, and provide a complex sample that will handle talking to Active Directory, but don&#8217;t have one do handle ordinary Unix passwd access.<span id="more-152"></span></p>
<p>Totally annoying.  A simple Perl script fixed it.  Don&#8217;t know why they didn&#8217;t put it in their samples, though.</p>
<pre>#!/usr/bin/perl

use strict;
use warnings;

=head1 NAME p4_check_passwd

Called with the user name on the command line and the password on standard
input, this program returns a success or failure depending on that password's
correctness.

Uses getpwnam to do so, and must run as root on in shadow group to access
/etc/shadow and password data.

This should be configured in p4 triggers as an auth-check trigger:

Triggers:
unixpw auth-check auth "/home/perforce/bin/p4_check_passwd.pl %user%"

This uses the crypt system call, which should handle any variants of encryption
in your password file. It also uses the getpwnam() function to access
the password data, so should be able to access data from NIS or other
configured password system.

=cut

# Perforce wants all messages on stdout. Guarantee that.
open(STDERR, "&gt;&amp;STDOUT") or die "Can't redirect to stdout\n";

# Get the user name
my $username = shift;
die "Need user name on command line\n" unless $username;

# Get the password
my $password = &lt;STDIN&gt;;
chomp $password;

# Get username and password from the system
my ($name, $passwd) = getpwnam($username);

die "Can't log in as $username\n" unless ($name and $username eq $name);
die "Can't access encrypted passwords\n" if(not defined $passwd or $passwd eq ''
or $passwd eq 'x');

# Check password and return correct exit code or die.
if(crypt($password, $passwd) eq $passwd) {
	exit 0; # Silent, successful exit worked!
} else {
	die "Can't log in as $username\n";
}</pre>
<p>Works for me, anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.laufeyjarson.com/2012/02/perforce-auth-check-trigger-for-unix-passwd-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Foswiki for Role Playing</title>
		<link>http://blog.laufeyjarson.com/2011/11/foswiki-for-role-playing/</link>
		<comments>http://blog.laufeyjarson.com/2011/11/foswiki-for-role-playing/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 00:28:50 +0000</pubDate>
		<dc:creator>Laufeyjarson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=145</guid>
		<description><![CDATA[Foswiki has enough access controls to allow it to handle players and games.  If you set it up properly, it works very well. Step 1: Install Foswiki Follow the installation instructions.  Using CGI is easiest to set up, if you watch the gotcha I found with running bin/configure.  FCGI is much faster, and works well [...]]]></description>
			<content:encoded><![CDATA[<p>Foswiki has enough access controls to allow it to handle players and games.  If you set it up properly, it works very well.</p>
<p>Step 1: Install Foswiki</p>
<p>Follow the installation instructions.  Using CGI is easiest to set up, if you watch the gotcha I found with running bin/configure.  FCGI is much faster, and works well once you install the extension, and if your host supports it.  (Mine does!)</p>
<p>I have had a little trouble getting the Apache config right, and have had to make several changes to get it working in my webserver configuration.  Make sure the virtual host is correct (not the default *), that the logs are as you want them, and to add a redirect for / to /foswiki/ if you want that.</p>
<p>Step 2: Configure Foswiki</p>
<p>Use the bin/configure script to configure Foswiki.  Mostly this is paths and mail.  Add the FastCGI if you want to use that.</p>
<p>Step 3: Add Admin Users</p>
<p>I like to create a user (or users) for administration and put them in the AdminGroup so they have full rights to everything.  This is easier than using the special admin user.  I like to create a &#8220;FirstnameAdmin&#8221; user &#8211; I&#8217;m LouAdmin, usually &#8211; for each administrator.  Get the admin to create them and then use the magic &#8216;admin&#8217; user to add them to the AdminGroup.</p>
<p>Step 4: Add Game Groups</p>
<p>For each game, you&#8217;ll want two groups.  GamePlayers and GameGMs.  Create them, using tools in Main/WikiGroups</p>
<p>Step 5: Add Users</p>
<p>Have the GM(s) and player(s) create accounts.  Add them appropriately to the GM and Player groups for each game.  The GMs does not have to be in the player group.</p>
<p>Step 6: Add Webs</p>
<p>Create a Web for GamePlayers and GameGMs.  (System/ManagingWebs).  Then, set each of those to be limited to the the correct groups.  Go to the WebPreferences setting for each web (GamePlayers/WebPreferences, for example) and update ALLOWWEBVIEW to the appropriate groups.  The Player web should have the players and the GMs, and the GMs should have only the GMs.</p>
<p>The GM web should look something like this:</p>
<ul>
<li>Set DENYWEBVIEW =</li>
<li>Set ALLOWWEBVIEW = %USERSWEB%.GameGMsGroup, %USERSWEB%.AdminGroup</li>
<li>Set DENYWEBCHANGE =</li>
<li>Set ALLOWWEBCHANGE =</li>
<li>Set DENYWEBRENAME =</li>
<li>Set ALLOWWEBRENAME =</li>
</ul>
<p>The Players web is the same, but includes the players in ALLOWWEBVIEW:</p>
<ul>
<li>Set ALLOWWEBVIEW = %USERSWEB%.GameGMsGroup, %USERSWEB%.GamePlayersGroup, %USERSWEB%.AdminGroup</li>
</ul>
<div>Step 7: Clean Up</div>
<div>The above get you per-group webs that players and GMs can use properly.  The default page layouts have a bunch of extra stuff on them that can be adjusted, as you desire.</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.laufeyjarson.com/2011/11/foswiki-for-role-playing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a Wiki for Role Playing Games</title>
		<link>http://blog.laufeyjarson.com/2011/11/using-a-wik-for-role-playing-games/</link>
		<comments>http://blog.laufeyjarson.com/2011/11/using-a-wik-for-role-playing-games/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 23:16:38 +0000</pubDate>
		<dc:creator>Laufeyjarson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=143</guid>
		<description><![CDATA[I have run Role Playing Games (RPGs) for some time, and played in them for longer.  One of the things that comes up as useful is ways for the players to sort and organize their notes, discoveries, etc., and for the Game Master (GM) to do the same thing. In this modern age, where many [...]]]></description>
			<content:encoded><![CDATA[<p>I have run Role Playing Games (RPGs) for some time, and played in them for longer.  One of the things that comes up as useful is ways for the players to sort and organize their notes, discoveries, etc., and for the Game Master (GM) to do the same thing.</p>
<p>In this modern age, where many (if not all) of the people at my gaming table have laptops or tablets, the use of a Wiki should be perfect.  However, many wikis have a strong feeling of &#8220;The Wiki Way&#8221;, which says everyone should be able to see and edit everything so that the experience and knowledge of everyone can be gathered and stored.</p>
<p>There&#8217;s at least two problems with this for a gaming Wiki.  First, the gaming Wiki&#8217;s probably on the Internet, where &#8220;anyone can edit&#8221; translates into &#8220;instantly defaced by spammers&#8221;.  That&#8217;s not ever good, and it seems to be ignored by many of the Wiki packages.</p>
<p>The second problem is that the GM needs a private place on the Wiki to conspire against the players.  If there&#8217;s more than one GM collaborating, they need to share information.  The players need to be kept out, so the things there can be a surprise when the game plays out.</p>
<p>It&#8217;s great if the players have a place to put their collective notes and information as well.  Some GMs want access to those, and some won&#8217;t.  Some will think these should be hidden to only players in the game, and some won&#8217;t.  (If the player characters are doing anything salacious or gaming anything subversive, it is perhaps best not to have those on Google.)</p>
<p>Enter Foswiki.  Foswiki allows access control by groups.  The next articles will detail how to set up Foswiki for RPG use.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.laufeyjarson.com/2011/11/using-a-wik-for-role-playing-games/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Foswiki 1.1.3 Fast CGI installation</title>
		<link>http://blog.laufeyjarson.com/2011/11/foswiki-1-1-3-fast-cgi-installation/</link>
		<comments>http://blog.laufeyjarson.com/2011/11/foswiki-1-1-3-fast-cgi-installation/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 04:51:24 +0000</pubDate>
		<dc:creator>Laufeyjarson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[foswiki]]></category>

		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=138</guid>
		<description><![CDATA[This took me a long time, and a trip to the IRC channel to sort out. When you install Foswiki, the installaiton guide sends you to an Apache Config File Generator. One of the options is to use cgi, or Fast CGI. Since I&#8217;ve used Fast CGI before and I know it works on my [...]]]></description>
			<content:encoded><![CDATA[<p>This took me a long time, and a trip to the IRC channel to sort out.  </p>
<p>When you install Foswiki, the installaiton guide sends you to an Apache Config File Generator.  One of the options is to use cgi, or Fast CGI.  Since I&#8217;ve used Fast CGI before and I know it works on my server, I selected that.</p>
<p>I got the configure program running, but the wiki would only 404.</p>
<p>I dug in and discovered the FastCGI configuration uses a foswiki.fcgi script, which wasn&#8217;t anywhere in my archive.</p>
<p>There&#8217;s a reason: It&#8217;s an extension you have to install.  Foswiki dosen&#8217;t ship with FastCGI support.</p>
<p>You can install it through Configure; go to Extensions, click the Find and Install Extensions button, then install FastCGIEngineContrib.</p>
<p>A kind user there, gac410, knew this and got me straightened right out right away.  Thanks again, gac!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.laufeyjarson.com/2011/11/foswiki-1-1-3-fast-cgi-installation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Quirk Installing Foswiki 1.1.3</title>
		<link>http://blog.laufeyjarson.com/2011/10/quirk-installing-foswiki-1-1-1/</link>
		<comments>http://blog.laufeyjarson.com/2011/10/quirk-installing-foswiki-1-1-1/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 15:37:20 +0000</pubDate>
		<dc:creator>Laufeyjarson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[foswiki]]></category>

		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=136</guid>
		<description><![CDATA[When I installed Foswiki 1.1.3, they sent me to a very handy ApacheConfigGenerator. One of the options is to use &#8220;short&#8221; urls, where you can use /Web/PageName instead of /bin/view/Web/PageName Naturally, I turned this on. Then I tried to run the &#8220;configure&#8221; script. It wouldn&#8217;t run, telling me I needed to run configure. The short-url [...]]]></description>
			<content:encoded><![CDATA[<p>When I installed Foswiki 1.1.3, they sent me to a very handy ApacheConfigGenerator. One of the options is to use &#8220;short&#8221; urls, where you can use /Web/PageName instead of /bin/view/Web/PageName</p>
<p>Naturally, I turned this on.</p>
<p>Then I tried to run the &#8220;configure&#8221; script. It wouldn&#8217;t run, telling me I needed to run configure.</p>
<p>The short-url change aliases / to bin/view. That includes &#8216;configure&#8217;.</p>
<p>In short, don&#8217;t use the Short URL option until you&#8217;re done with configure, or turn it off to do so.</p>
<p>Commenting out the three lines in the Apache config is enough to turn it off briefly to run configure.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.laufeyjarson.com/2011/10/quirk-installing-foswiki-1-1-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Can&#8217;t really override open()?</title>
		<link>http://blog.laufeyjarson.com/2010/12/cant-really-override-open/</link>
		<comments>http://blog.laufeyjarson.com/2010/12/cant-really-override-open/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 05:18:35 +0000</pubDate>
		<dc:creator>Laufeyjarson</dc:creator>
				<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=127</guid>
		<description><![CDATA[A question came up at work the other day, if you could override the Perl open() function.  There&#8217;s many possible uses for this, but work&#8217;s was simple: we wanted a log of all files accessed during a program run.  The program is large, complex, and uses many modules.  An override of open() would let us [...]]]></description>
			<content:encoded><![CDATA[<p>A question came up at work the other day, if you could override the Perl open() function.  There&#8217;s many possible uses for this, but work&#8217;s was simple: we wanted a log of all files accessed during a program run.  The program is large, complex, and uses many modules.  An override of open() would let us record the file and open mode, then call CORE::open.</p>
<p>We couldn&#8217;t do it.  After a second look, I still can&#8217;t do it.  Not for all cases, anyway.<span id="more-127"></span></p>
<p>perlsub says lists a prototype of (*;$) for open, and discusses being careful not to override open by accident.  It also suggests prototype can show the prototypes for overridable items.</p>
<p>prototype &#8216;CORE::open&#8217; returns &#8220;*;$@&#8221;, which is interesting, but not a match for perlsub.  &#8221;*;$@&#8221; lets the function get called, though, and matches all the things open has to do.</p>
<p>I wrote a really simple wrapper for open:</p>
<pre> use Data::Dumper;</pre>
<pre>sub open(*;$@) {</pre>
<pre>    say Dumper(\@_);</pre>
<pre>}</pre>
<p>I wrote a function to call it a couple of ways:</p>
<pre>say "test 1:";</pre>
<pre>open (FH, '&gt;file.txt') or die "Can't &gt;file.txt: $!";</pre>
<pre>close FH;</pre>
<pre>say "test 2:";</pre>
<pre>open (FH, '&gt;', 'file.txt') or die "Can't &gt; file.txt: $!";</pre>
<pre>close FH;</pre>
<pre>say "test 3:";</pre>
<pre>open (my $fh, '&gt;', 'file.txt') or die "Can't my &gt; file.txt: $!";</pre>
<pre>close $fh;</pre>
<p>Now I can see what those look like:</p>
<pre>test 1:</pre>
<pre>$VAR1 = [</pre>
<pre>     'FH',</pre>
<pre>     '&gt;file.txt'</pre>
<pre> ];</pre>
<pre>test 2:</pre>
<pre>$VAR1 = [</pre>
<pre>     'FH',</pre>
<pre>     '&gt;',</pre>
<pre>     'file.txt'</pre>
<pre> ];</pre>
<pre>test 3:</pre>
<pre>$VAR1 = [</pre>
<pre>     undef,</pre>
<pre>     '&gt;',</pre>
<pre>     'file.txt'</pre>
<pre> ];</pre>
<p>Okay.  The two calls with typeglobs get the name of the glob.  I can work with that.</p>
<p>The call with a lexical, though, gets the value.  Where/how do I return the handle?</p>
<p>I messed around some more, and when using lexicals, a Perl open() function is called with the value of the lexical, not with any way to identify the variable itself.  I can&#8217;t figure out how to get the variable to pass to CORE::open, or to return something into it.</p>
<p>And there I&#8217;m stumped.  Is it possible that the docs in perlsub are from the 5.5 days and don&#8217;t work since Perl 5.6 introduced lexicals as file handles?  Or am I missing something?</p>
<p>I could go dig in to CPAN and see if any other modules do this right.  How does Safe.pm do it?  Can it be done in an XS module but not in Perl?</p>
<p>Back to useful work instead of banging my head against this.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.laufeyjarson.com/2010/12/cant-really-override-open/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Cool Tools To Know</title>
		<link>http://blog.laufeyjarson.com/2010/12/cool-tools-to-know/</link>
		<comments>http://blog.laufeyjarson.com/2010/12/cool-tools-to-know/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 01:28:27 +0000</pubDate>
		<dc:creator>Laufeyjarson</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[cpan]]></category>

		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=116</guid>
		<description><![CDATA[chromatic mentioned something in the preface to his book Modern Perl that I had been looking for but hadn&#8217;t yet found.  He then went on to mention a couple of other things which were just plain neat.  I knew about one of them, but not the second and thought they were both great ideas and [...]]]></description>
			<content:encoded><![CDATA[<p>chromatic mentioned something in the preface to his book <a title="Modern Perl - book and download" href="http://www.onyxneon.com/books/modern_perl/index.html" target="_blank">Modern Perl</a> that I had been looking for but hadn&#8217;t yet found.  He then went on to mention a couple of other things which were just plain neat.  I knew about one of them, but not the second and thought they were both great ideas and thought I&#8217;d try and get them wider attention.<span id="more-116"></span></p>
<p>I&#8217;d been looking for a way to manage having multiple Perl installations on my system.  Ruby has something called the <a title="rvm - Ruby Version Manger" href="http://rvm.beginrescueend.com/" target="_blank">Ruby Version Manager</a> which makes this really straightforward, and I figured there had to be something like it for Perl.  I hadn&#8217;t looked much, but what I had didn&#8217;t get me anywhere.  The Preface for Modern Perl mentioned it in passing.  The tool is called <a title="App::perlbrew" href="http://search.cpan.org/perldoc?App%3A%3Aperlbrew" target="_blank">App::perlbrew</a> and allows you to easily switch from one Perl to another and can help manage those Perl installations.</p>
<p>Combine that with <a title="local::lib" href="http://search.cpan.org/perldoc?local%3A%3Alib" target="_blank">local::lib</a> so you can have your own installed modules, and you&#8217;ve almost got rvm.  The ability to have named module sets and turn them on and off at will is missing.  If it&#8217;s important, the two could be combined into a complete Perl environment management tool&#8230; but I don&#8217;t know if it is important.  A per-project Perl with modules installed might be enough.</p>
<p>One useful tool mentioned in Modern Perl is the Perl module <a title="Modern::Perl" href="http://search.cpan.org/perldoc?Modern%3A%3APerl" target="_blank">Modern::Perl</a>, also by chromatic.  It&#8217;s a helper to take some of the boilerplate that a modern Perl program should put in every program and module and condense it to one easy to read, clearer line of code.  It isn&#8217;t a big deal, but is nice.  (CPAN, as usual was full of similar things, but I didn&#8217;t think they were as well thought.)  I had heard of Modern::Perl because I&#8217;d been following chromatic&#8217;s blog.</p>
<p>The module I thought was really neat but hadn&#8217;t heard of was <a title="Task::Kensho" href="http://search.cpan.org/perldoc?Task%3A%3AKensho" target="_blank">Task::Kensho</a>.  This is part of the work of a group of folks who are trying to build an &#8220;Enlightened Perl&#8221; and is mostly references to other modules.  The module list includes some big stuff I&#8217;d run into &#8211; Moose, DBIx::Class &#8211; but also included a lot of just generally useful stuff that I&#8217;m sure will be handy.  There was also some things that were not critical but neat, like <a title="Smart::Comments" href="http://search.cpan.org/perldoc?Smart%3A%3AComments" target="_blank">Smart::Comments</a>.  There&#8217;s a bunch of stuff on that list I&#8217;ve been Meaning To Look At but haven&#8217;t gotten around to yet, like <a title="Devel::REPL" href="http://search.cpan.org/perldoc?Devel%3A%3AREPL" target="_blank">Devel::REPL</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.laufeyjarson.com/2010/12/cool-tools-to-know/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Linking to CPAN</title>
		<link>http://blog.laufeyjarson.com/2010/11/linking-to-cpan/</link>
		<comments>http://blog.laufeyjarson.com/2010/11/linking-to-cpan/#comments</comments>
		<pubDate>Sat, 27 Nov 2010 18:12:43 +0000</pubDate>
		<dc:creator>Laufeyjarson</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[perl CPAN]]></category>

		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=118</guid>
		<description><![CDATA[All through these blog pages, I&#8217;ve been linking to CPAN modules I&#8217;m talking about so that it&#8217;s easy for readers to find them.  I knew I was linking to specific versions, but couldn&#8217;t figure out how to link to the latest version of the module.  I noticed the docs for Task::Kensho do it, and am [...]]]></description>
			<content:encoded><![CDATA[<p>All through these blog pages, I&#8217;ve been linking to CPAN modules I&#8217;m talking about so that it&#8217;s easy for readers to find them.  I knew I was linking to specific versions, but couldn&#8217;t figure out how to link to the latest version of the module.  I noticed the docs for <a title="Task::Kensho" href="http://search.cpan.org/perldoc?Task%3A%3AKensho" target="_blank">Task::Kensho</a> do it, and am going to start doing it too.</p>
<p>The secret is to use links like this:  http://search.cpan.org/perldoc?Task%3A%3AKensho</p>
<p>The %3A are the URI encoding of a : so this goes to http://search.cpan.org/perldoc and searches for the module name automatically.  Neat.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.laufeyjarson.com/2010/11/linking-to-cpan/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Shiny New Perl &#8211; Modern Perl!</title>
		<link>http://blog.laufeyjarson.com/2010/11/shiny-new-perl-modern-perl/</link>
		<comments>http://blog.laufeyjarson.com/2010/11/shiny-new-perl-modern-perl/#comments</comments>
		<pubDate>Sat, 20 Nov 2010 17:07:13 +0000</pubDate>
		<dc:creator>Laufeyjarson</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[modern perl]]></category>
		<category><![CDATA[modern_perl]]></category>

		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=112</guid>
		<description><![CDATA[I wrote a post last week talking about how outdated a lot of Perl seems to be, and the comments were full of people discussing it.  One of the things mentioned repeatedly was chromatic&#8216;s new book Modern Perl.  I had seen several of the posts where he discussed the book on his blog and knew [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a post last week talking about how outdated a lot of Perl seems to be, and the comments were full of people discussing it.  One of the things mentioned repeatedly was <a title="chromatic's blog" href="http://www.modernperlbooks.com/mt/index.html" target="_blank">chromatic</a>&#8216;s new book <a title="Modern Perl, print and download" href="http://www.onyxneon.com/books/modern_perl/index.html" target="_blank">Modern Perl</a>.  I had seen several of the posts where he discussed the book on his blog and knew it was coming, but it was news to me that it was released</p>
<p>Not only is it released, but chromatic has <a title="Modern Perl announcement" href="http://www.modernperlbooks.com/mt/2010/11/the-book-is-out.html" target="_self">graciously</a> made the book available  for download as PDF.  His publisher has it as both <a title="Modern Perl - letter sized" href="http://www.onyxneon.com/books/modern_perl/modern_perl_letter.pdf" target="_blank">letter-sized</a> and <a title="Modern Perl - A4" href="http://www.onyxneon.com/books/modern_perl/modern_perl_a4.pdf" target="_blank">A4 sized</a> formats for print.  It&#8217;s released under one of the Creative Commons (<a title="By Attribution, Non-Commercial, No Derivitaves" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" target="_blank">by-nc-nd</a>) licenses so you can use it, share it, and distribute it freely and widely.  The blog announcement mentioned above encourages you to do so.<span id="more-112"></span></p>
<p>I&#8217;ve taken the time to give the book a first read, and I can only say that I&#8217;m impressed.  According to the blog posts, the book was produced in POD which was stored in a public Git repository for constant feedback and refinement from members of the community.  That&#8217;s really slick, and the content of the book shows how much work went into it.</p>
<p>The book does some things differently than other Perl books I&#8217;ve read, and I approve.  The preface starts of by giving the requirements for running the sample code from the book.  That includes Perl of no later than 5.10.1, and &#8220;use strict&#8221; and &#8220;use warnings&#8221;.  There is no example of trying to write code that works in Perl 5.6 or is just like the other things you&#8217;ve seen before .</p>
<p>It begins with some interesting sections discussing the philosophy of Perl, and where the community lives and how to find them.  It explains perldoc and search.cpan.org, and leaves it to the reader to use those as references.  These are key items often overlooked in books, and rightly deserve a place at the front of the book.</p>
<p>There are several chapters about Perl, the language.  These chapters cover almost all of the language.  They cover it at some depth, pausing to explain how it works and to shine a flashlight into the dark corners and point out all the odd bits you can trip over.  These chapters manage to be easily readable and to avoid most of the technical jargon they don&#8217;t need.  When a technical term is needed, it is introduced, explained and then used properly.</p>
<p>The book includes the best description of <em>arity</em> and <em>fixity</em> I&#8217;ve ever seen.  I&#8217;d gathered the concepts, but didn&#8217;t know the names.   I knew the names of the different kinds of operators &#8211; <em>infix</em>, <em>prefix</em>, <em>circumfix</em>, and <em>postcircumfix</em>, but have never seen them described so well.  Similarly, this is the clearest and most concise description I&#8217;ve ever read of <em>closures</em>, including what they are, why they work, why they&#8217;re called &#8220;closures&#8221; and why they&#8217;re interesting.</p>
<p>In addition, the book has the best explanation of why it is important to handle different character sets properly that I have ever seen.  It demonstrates some of the common pitfalls and shows how simple it is to accidentally produce strings which will be unreadable in any format because they&#8217;ve got data from two different character sets.  For anyone who isn&#8217;t paying attention to Unicode yet, this should be a mandatory read.</p>
<p>There are two chapters on object oriented Perl.  The book starts with Moose and shows its use and how to use it.  Only then does it show the built-in Perl OO constructs.  They&#8217;re a lot easier to explain once you&#8217;ve seen how objects should work, so you might have a grasp of why you&#8217;d be writing a &#8220;new&#8221; function.  They are well done chapters.</p>
<p>Then come what I considered the important parts!  There are chapters on how to write maintainable code, and what that means.  A chapter discusses some of the common idioms seen on the Internet and on CPAN.  There is a chapter including testing, warnings, and distributions.  There&#8217;s a chapter that goes &#8220;beyond syntax&#8221; to cover why things are done and how to do them well and explains a couple of the common methods used, such as the Schwartzian Transform.  Finally, there is a &#8220;things to avoid&#8221; chapter and some things chromatic feels are missing from Perl.</p>
<p>I think all of these things are useful and important, and didn&#8217;t see anything in the book I strongly disagree with.  I read things I didn&#8217;t know, ranging from silly little features (you can us ++ on a string!) to the names of some of the computer science concepts I&#8217;d never heard well explained before.  The coverage of the language and how it works is excellent, and reading this will help people go from fumbling with it, to really understanding how it works and why it does the things it does.</p>
<p>My biggest complaint about the book is that I wish there were more of the discussion about writing good Perl.  One of the common complaints about Perl is that it&#8217;s ugly, and unmaintainable.  It doesn&#8217;t have to be, and there are a lot of techniques to make it better.  I&#8217;d have loved to see more discussion of that in this book.  (I realize I have no one to blame but myself, as this book was produced with the collaboration of many and I could have been involved.)</p>
<p>I also just noticed a language feature it missed discussing &#8211; formats.  They are another dark corner, but I&#8217;m surprised they aren&#8217;t there.  Maybe I missed them, but neither a search nor the index shows them.</p>
<p>As you can see, I don&#8217;t have much to complain about here, and I&#8217;m going to be sending this book around on the internal Perl mailing lists at work.  I feel it&#8217;s an excellent place for an intermediate Perl programmer to go to get a really firm grasp on the language and will be an unbeatable way to help many of the self-taught engineers who write Perl to solidify and put names to the concepts they&#8217;ve been working with but may not have had such a clear grasp of.</p>
<p>At this point, I&#8217;d consider this a more valuable book than &#8220;Programming Perl&#8221; since it contains so much information about the language that isn&#8217;t just in the perldoc.  It&#8217;s also less idiosyncratic and contains many fewer in-jokes.  It&#8217;s a much more useful and professional book, and I recommend it.</p>
<p>Yeah, you could say that I liked it.</p>
<p>Thank you, chormatic, for the time, work, and effort to produce this!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.laufeyjarson.com/2010/11/shiny-new-perl-modern-perl/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Ugly Old Perl</title>
		<link>http://blog.laufeyjarson.com/2010/11/ugly-old-perl/</link>
		<comments>http://blog.laufeyjarson.com/2010/11/ugly-old-perl/#comments</comments>
		<pubDate>Sat, 13 Nov 2010 19:08:36 +0000</pubDate>
		<dc:creator>Laufeyjarson</dc:creator>
				<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=103</guid>
		<description><![CDATA[I work as a professional Perl developer.  We have a large and complex system which is built around a lot of Perl.  This system has been in use and in place for years, and handles an astonishing amount of load, using thousands of computers to do it. I work with some excellent engineers, who are [...]]]></description>
			<content:encoded><![CDATA[<p>I work as a professional Perl developer.  We have a large and complex system which is built around a lot of Perl.  This system has been in use and in place for years, and handles an astonishing amount of load, using thousands of computers to do it.</p>
<p>I work with some excellent engineers, who are thoughtful, intelligent, hard-working folks.  They want to make the best system they can, and they want it to be reliable and dependable.  I have great co-workers.</p>
<p>I keep finding Perl that looks like it was written in 1990.   I find code like this:<span id="more-103"></span></p>
<blockquote>
<pre>sub logger {</pre>
<pre>    my $msg = shift;</pre>
<pre>    open(FH, "&gt;&gt;$runpath/log/output.log ")
        || die "Can't write output.log!"</pre>
<pre>    print FH "$0:  $msg\n";</pre>
<pre>    close(FH);</pre>
<pre>}</pre>
</blockquote>
<p>(Edit: Fixed the mistake that made the sample useless.  Mark Dominus pointed out in the comments that you can&#8217;t write to a read-only file handle.  &lt;&lt; was wrong.)</p>
<p>The first dozen times I found code like this I thought to myself, &#8220;Ugh, old Perl.  Been here for ever.&#8221; and cleaned it up.  This is an old codebase &#8211; parts of it still have to be compatible with Perl 5.6, for instance &#8211; and these constructs weren&#8217;t so badly dated when the project began.</p>
<p>I had to stop thinking this while doing a code review of a new change.  Filehandles used with the two-parameter open in brand-new code.</p>
<p>I stopped and asked the engineer why they&#8217;d done this.  They looked at me like I was insane.  Of course they&#8217;d done it that way &#8211; that&#8217;s how you open files in Perl.  I had questions: &#8220;What about using a lexical instead of the typeglob?&#8221;  &#8220;What about using the safer, clearer three-parameter form of open?&#8221;</p>
<p>I got blank stares.  None of them had ever heard of these changes to open.</p>
<p>I&#8217;ve been educating them, which has been interesting.  I&#8217;ve also been thinking about how we got here.</p>
<p>There&#8217;s two things I see that led to this situation, and both of them are bad for Perl.</p>
<p>First, many of these engineers aren&#8217;t aware that Perl is still being developed.  Perl 5.8 was so stable for so long, they&#8217;ve quit watching.  They think it&#8217;s done, and there&#8217;s nothing new under the sun.  They bought &#8220;Learning Perl&#8221; and &#8220;Programming Perl&#8221; in 1991 and are happy with both of them.  Neither of those books mentions lexical filehandles  I realized the copy of &#8220;Programming Perl&#8221; on my own bookshelf didn&#8217;t.</p>
<p>Second, it seems like lots of people quit learning about what they&#8217;re using.  It&#8217;s done, carved in stone, and that&#8217;s how they use it.  The idea that the Perl community exists is odd to them, and apparently irrelevent.  The ideas that Perl&#8217;s idioms might change or that new libraries, tools, and language constructs come along&#8230; these are hard ideas to convey, apparently.  The question I keep getting asked it, &#8220;What&#8217;s the benefit for making these changes?  What I do works, why should we change?&#8221;</p>
<p>Luckily for me, the project leads and our managers do understand why keeping up with the language is important, and I&#8217;m not swimming against the current to try and be bringing this new information to the team.  Even so, there&#8217;s a couple of big rocks we&#8217;re having to go around.</p>
<p>How can the Perl community get past this huge piece of old information about the language?  There are a million web sites with old examples, and thousands of outdated copies of the O&#8217;Reilly books on bookshelves.  What can the community do to make it widely known that these are old, and that Perl Is Not Dead and that not only is There More Than One Way To Do It, there&#8217;s probably a Better Way now.</p>
<p>I worry that the addition of Perl 6 to the mix will actually make this worse.  Searching for it will be hard, and how will you find examples for one or the other?</p>
<p>I honestly wonder if *both* languages shouldn&#8217;t change their names.  Leave Perl 5 in maintenance mode forever and branch it to a new language, even if it&#8217;s just Perl 5 with better documentation.  Take that time to reconsider the core modules, clean up some historical messes and release it as something new.  Something that can still use CPAN, can still run all your Perl, but has active development and real, usable tools.  I&#8217;d give Perl 6 a new name, too, so you can search for it properly.</p>
<p>Or maybe that&#8217;s the worst idea ever.  I don&#8217;t know.  I worry that Perl is in a bad spot now, and is trapped in the past.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.laufeyjarson.com/2010/11/ugly-old-perl/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
	</channel>
</rss>

