Simon's Journal
http://use.perl.org/~Simon/journal/
Simon's use Perl Journalen-ususe Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.2012-01-25T02:01:59+00:00pudgepudge@perl.orgTechnologyhourly11970-01-01T00:00+00:00Simon's Journalhttp://use.perl.org/images/topics/useperl.gif
http://use.perl.org/~Simon/journal/
Moved!
http://use.perl.org/~Simon/journal/6562?from=rss
Want to follow my blog without ever leaving use.perl? The <a href="http://use.perl.org/users.pl?op=previewbox&bid=simoncozens">use.perl RSS Feed</a> lets you check up on me without leaving the house!Simon2002-07-23T08:12:59+00:00journalGoodbye
http://use.perl.org/~Simon/journal/6181?from=rss
<a href="http://www.oreillynet.com/~rael/lang/perl/blosxom/">Blosxom</a> is lovely, and lets me take my blog <a href="http://blog.simon-cozens.org/">home</a>. So I'll be writing from there from now on. Oh, yes, and importing the use.perl blog into blosxom was quite fun. <p>
So, bye for now, hope you'll catch the blog at its new home - oh, and <code>Config::Auto</code> is out.</p>Simon2002-07-04T22:43:03+00:00journalWANT TO GO HOME!
http://use.perl.org/~Simon/journal/6155?from=rss
I want to go home, but I've got started hacking a really neat little Perl module, and I've only got two subroutines left to do. In fact, stuff it, I'm going home. I can finish this off tomorrow.<p>
So, about the module. It's called <code>Config::Auto</code>, and I've written it because I never want to write another config file parser ever again. So, this little baby looks around for a likely-looking config file, sniffs it to work out what sort of format it's in, and has a good shot at parsing it into a Perl data structure. It deals with XML, INI files, Perl files, lists and the more "vague" Unix-style colon-separated, equal-separated and space-separated files.
</p><p>
For instance:</p><blockquote><div><p> <tt># tortuous.pl<br>use Config::Auto; use Data::Dumper;<br>print Dumper(Config::Auto::parse());</tt></p></div> </blockquote><p>
This looks around my filesystem, and finds<nobr> <wbr></nobr><code>.tortuousrc</code>, which looks like this:</p><blockquote><div><p> <tt>test: foo=bar, baz=quuz<br>test2: blah<br>blez: quux</tt></p></div> </blockquote><p>And, with no other prompting, it comes back with:</p><blockquote><div><p> <tt>$VAR1 = {<br> 'test2' => 'blah',<br> 'blez' => 'quux',<br> 'test' => {<br> 'foo' => 'bar',<br> 'baz' => 'quuz'<br> }<br> };</tt></p></div> </blockquote><p>Laziness: check.<br>
Impatience: check.<br>
Hubris: check.</p>Simon2002-07-03T17:14:29+00:00journalSome thoughts on donation models
http://use.perl.org/~Simon/journal/6152?from=rss
In reply to a thread on Free Software Business:<blockquote><div><p>
I have two problems with the open source donation model.
</p><p>
The first is that open source projects are made from code, and the best
donation I can give them is not money but code. In the case of Perl, I
maintain nearly 40 modules, managed the release of the first few
versions of the Perl 6 interpreter, and have contributed many patches
and documents to the Perl 5 core. I feel absolutely no guilt at all for
not giving a single cent to the fundraising drive.
</p><p>
If all we did was throw money at a small number of people to get the
code written for us, there'd be no community to maintain.
</p><p>
Second, and far more seriously, donation models reinforce the myth that
software is important in any meaningful sense of the word. Of course,
software is relatively important to programmers, but for the vast
majority of the world, it's pretty meaningless.
</p><p>
I'm very lucky that I have the opportunity to give reasonable sums of
money to charity reasonably often. When this happens, I naturally have a
number of things vying for my donations. Here are a few:</p><ul>
<li> Work with homeless people in my home town.</li>
<li> Care for the elderly mentally ill.</li>
<li> Providing AIDS vaccines for children in Africa.</li>
<li> Digging wells and providing fresh water for villages in Pakistan.</li>
<li> Allowing privileged first-world programmers to sit in front of a
computer for more hours than they currently do.</li>
</ul><p>
Put like that, I hope it is clear that software is not as important as
the biased eye of a programmer may perceive. Indeed, no matter how much
of my income I derive from the existence of a given open source project,
it becomes very difficult for me to fail to take a global view in cases
like this. The common counterargument that I should donate money to Perl
because it provides my livelihood makes sense only for those who cannot
see beyond their own needs.
</p><p>
Meanwhile, I know full well that as Perl <b>is</b> an open source project,
it'll continue to be maintained and developed whether or not people are
paid to do this. This makes it even more difficult for me to help the
poor white-bread middle-class afflicted.
</p><p>
So I'm happy to contribute to Perl in my own way, but I'd rather not
lose my sense of priority.</p></div>
</blockquote>Simon2002-07-03T15:59:34+00:00journalIdea of the day
http://use.perl.org/~Simon/journal/6147?from=rss
I've just written something using Leon's excellent <code>GraphViz</code> module to turn a Shishi parser into a nice diagram of the state machine. While GraphViz turns a data structure into a graph, it would be really lovely for parser tuning to be able to play around with the graph in dotty and then read the resulting graph back into a data structure...Simon2002-07-03T13:21:03+00:00journalClass::Dynamic released
http://use.perl.org/~Simon/journal/6129?from=rss
This is a module I threatened to release to the world a while back. Do evil things with it...<blockquote><div><p> <tt>=head1 NAME<br> <br>Class::Dynamic - Rudimentary support for coderefs in @ISA<br> <br>=head1 SYNOPSIS<br> <br> package Blargh;<br> use Class::Dynamic;<br> our @ISA = ("Foo", sub { rand < 0.5 ? "Bar" : "Baz" } );<br> <br>=head1 DESCRIPTION<br> <br>This module allows you to insert coderefs into a class's C<@ISA>.</tt></p></div> </blockquote>Simon2002-07-02T16:37:11+00:00journalHome and tired
http://use.perl.org/~Simon/journal/6125?from=rss
I got back from YAPC yesterday after a reasonably sleepless night flight. I was slightly suspicious to find my mail sorted and the kitchen tidied. But I was too tired to work out what was going on, so had a bath and forced myself into work, which was possibly a bad idea. I took the rest of the day to catch up with what's been going on here, and then returned home to find, yes, I had indeed acquired a housekeeper.<p>
By way of explanation, a friend had been staying with someone who's since moved back to Japan; she then planned to move to Cheltenham, leaving her bags at my house for the time being. However, the Cheltenham idea also fell through and she was stuck in Oxford homeless. So she's staying with me for now.
</p><p>
At the airport on the way back, I managed to get a lot more done on Shishi, and so I've released the prototype to CPAN; I've also got a reasonable stab at an approximate Perl 6 regular expression compiler which compiles to a shishi parser. Unfortunately, it's got to the point where it's really very difficult to build up the data structures that I need from a simple-minded tokenization of a Perl 6 pattern, and I'm left trying to bootstrap Shishi by hand-coding a parser. This is not fun.
</p><p>
This morning, we finished the 6 week Perl course I've been teaching. We did half the lesson on CPAN modules, looking primarily at the modules in my "10 modules" talk from YAPC. Of course, we got to a demonstration of <code>LWP::Simple</code> just as the demonstration web server was being upgraded, so I had to puzzle over why one person's code worked fine, but someone else's identical code a few minutes later didn't work. In the second half, people built a news ticker utility out of <code>LWP</code>, <code>Mail::Send</code> and dodgy screen-scraping regexes. Good fun, and I think people finished the course with an idea of how to do relatively complex things in Perl - given that the previous course got to subroutines and just abruptly ended, I think adding the modules lesson was a big improvement.
</p><p>
And now, after a flight, a bad night's sleep, and about three hours teaching, I'm utterly shattered.</p>Simon2002-07-02T13:51:14+00:00journalDispatches from STL
http://use.perl.org/~Simon/journal/5933?from=rss
23/7/2002 - St. Louis
<p>
Woke up too early, and wrote a Perl 6 regular expression engine. Don't
you just hate it when that happens?
</p><p>
At 6:30, I headed off to find some coffee, which was more of an ordeal
than I expected. The hotel's on the edge of quite a small town, and
nothing opens until at least 7am. Finally, I wandered down past
Concordia seminary, and found a lovely little cheap and tasty coffee bar
on the corner. I got my stuff together and around 8:30 I was ready to
head into St. Louis itself.
</p><p>
This town, as a famous man once said, is coming like a ghost town. St
Louis is a weird, weird place. The car culture has driven a few of the
usual things you'd expect to see in a city out to the suburbs. Basic
things like "shops" and "people". Until around noon today, there was
essentially nobody on the streets apart from me. (Granted, it was a
Sunday.)
</p><p>
Even when the city started to liven up, I couldn't help noticing, while
I was wandering around, that there wasn't really a central business
district. There were a few delis, pharmacies and 7/11s dotted around,
but not even so many of those. Instead, many of the downtown streets
were filled with empty buildings, boarded up doors and the shells of
long-dead shops. It was bizarre. Some of the most wonderful urban
architecture I've seen in a prime position in the city center was just
lying empty and forgotten. Even the St. Louis Center, a four storey
shopping and restaurant complex, hadn't really taken off. Many of the
units remained closed, and those which were let were not exactly
inspiring.
</p><p>
The only signs of real civilization were the Busch baseball stadium, -
complete with crowds of mourners for legendary baseball radio announcer
Jack someone-or-other - the old Union Station, - now a restaurant complex -
and the Gateway Arch - long queues and tight security. It took me half
the day to find somewhere which would sell batteries, and then I took
another few hours taking pictures of some of the great yet desolate
buildings I'd seen. Finally, an hour long trip on a Mississippi steamer,
before ordering a van ride back to the hotel. Then writing, writing,
writing.
</p><p>
The language barrier is turning out to be a problem. I ordered a
cheesesteak from the St. Louis Center when it finally opened, and was
startled to be asked by the server "Why do we pray?" Well, I wasn't
really in the mood for theological discussions, so I just shrugged. This
wasn't enough. "Why do we pray?" This a trick question, isn't it? The
server got agitated, and picked up two bags of rolls. "Why do we pray?"
</p><p>
Realisation dawned. "Oh, um, wheat, please."</p>Simon2002-06-25T15:33:17+00:00journalTired
http://use.perl.org/~Simon/journal/5788?from=rss
Tonight, I: reviewed four chapters of galleys, ported Magicpoint to OS X, (No, I didn't ever enter the command <code>vi<nobr> <wbr></nobr>/usr/include/stdio.h</code>, no, not at all.) ran over my tutorial for tomorrow, despatched perl.com for the week, and had a few drinks with co-workers.
<p>
I think I'm allowed to feel tired after that.</p>Simon2002-06-19T23:06:24+00:00journalTwin peaks
http://use.perl.org/~Simon/journal/5778?from=rss
<a href="http://www.nypost.com/news/nationalnews/50613.htm">Submitted without comment.</a>Simon2002-06-19T16:03:11+00:00journalGreat Minds Think Alike.
http://use.perl.org/~Simon/journal/5775?from=rss
Today Arnar Hrafnkelsson asked my opinion on a module he'd been working on called <code>Regexp::Open</code>. It's neat, it's a state machine implemented in C with an XS interface to it. I took a look at it and realised the concept looked a little familiar.
<p>
He was just telling me about how he could use it to dynamically change the state machine at runtime when I pointed him at the <a href="http://squash.oucs.ox.ac.uk/cgi-bin/viewcvs.cgi/shishi">shishi repository</a>...</p>Simon2002-06-19T15:35:36+00:00journalPeople are ingenious
http://use.perl.org/~Simon/journal/5734?from=rss
On the Perl course I'm doing, I give out a lot of programming assignments. Last week, people wrote something to get five names and favourite colours from the user, stored each one into a hash, and then wrote out the hash as a colon-delimited file.
<p>
This week, I showed them about <code>split</code> and asked them to write something to read the hash back in, and prompt for a name, then display that user's favourite colour. One of the students - a bright girl - said "Why should I use a hash?" and came up with something like this:</p><blockquote><div><p> <tt>use strict;<br>open IN, "favourites.txt" or die $!;<br> <br>print "Who do you want to know about? ";<br>my $input = <STDIN>;<br>chomp $input;<br> <br>while (<IN>) {<br> chomp;<br> my ($name, $colour) = split<nobr> <wbr></nobr>/:/;<br> if ($input eq $name) {<br> print "$name's favourite colour is $colour\n";<br> }<br>}</tt></p></div> </blockquote><p>
What can you say? It's decent code, it fulfils the spec, it just wasn't exactly what I had imagined. Ah, the fun of TMTOWTDI...</p>Simon2002-06-18T13:10:35+00:00journalDoublethink
http://use.perl.org/~Simon/journal/5715?from=rss
This is not a pointed question; I honestly don't know the answer.<p>
The reason the US government publically gives for moves against Iraq and Saddam Hussain is that Iraq is trying to develop "weapons of mass destruction" - nuclear weapons. Developing nuclear weapons is obviously a big no-no, which is why Iraq had to have the UN weapons inspectors in.
</p><p>
If this is the real reason (which I really doubt that it is) then why didn't America send the boys in when India or Pakistan went nuclear? And what goes on in the minds of these government folk that they can simultaneous believe that developing nuclear weapons is such a venial sin that we ought to go and assassinate the President, but the fact that the US already <b>has</b> nuclear weapons is good and proper? Obviously it's a flimsy excuse, but why has nobody called them up on it?</p>Simon2002-06-17T17:57:04+00:00journalSemantic ambiguity
http://use.perl.org/~Simon/journal/5704?from=rss
<p>"Free to good home - Baby carrying rucksack"</p>Simon2002-06-17T08:41:41+00:00journalActiveSnake
http://use.perl.org/~Simon/journal/5693?from=rss
ActiveState are now apparently profitable; much of this can be explained by their shift towards Python support and services.
<p>
The phrase "snake oil" takes on a whole new meaning.</p>Simon2002-06-16T21:33:57+00:00journalWhat trouble a few careless words can cause.
http://use.perl.org/~Simon/journal/5692?from=rss
<p>I have agreed to become a children's church assistant. (Which is obviously the PC version of "Sunday school teacher".) You are free to imagine your favourite BOFH attempting humility, patience and kindness towards a bunch of screaming five-to-thirteen year olds.</p>Simon2002-06-16T19:52:22+00:00journalSynopsis 5
http://use.perl.org/~Simon/journal/5676?from=rss
<a href="http://www.yetanother.org/damian/Perl6/Synopsis5.pdf">This</a> didn't get much attention, so here's another mention of it.Simon2002-06-15T07:01:16+00:00journalThanks, Gisle!
http://use.perl.org/~Simon/journal/5675?from=rss
<p>LWP rocks. We all know that. But when was the last time you sat down and thought about the fact that someone actually coded it, rather than it being the gift from above it might behave like?</p>Simon2002-06-15T06:58:23+00:00journalDream or nightmare?
http://use.perl.org/~Simon/journal/5674?from=rss
<p>You can tell it's a nightmare if it has clowns in it.</p>Simon2002-06-15T06:29:26+00:00journalAcme::Rant
http://use.perl.org/~Simon/journal/5652?from=rss
<a href="http://search.cpan.org/doc/KEVINRICE/Acme-Buckaroo-1.02/Buckaroo.pm">Acme::Fscking::Buckaroo</a>.<p>
Call me a boring young fart, (but you knew that already, right?) but I'm still amazed how many people can copy a <a href="http://search.cpan.org/doc/DCONWAY/Acme-Bleach-1.12/lib/Acme/Bleach.pm">mildly amusing idea</a> and still think they're being original and amusing.
</p><p>
So you can do source transformation. Good for you.
Don't people have either better or at least more amusing things to write? I guess not.
</p><p>
It's getting even more tedious than quoting the <a href="http://www.montypython.net/scripts/4york.php">Four Yorkshiremen</a>.</p>Simon2002-06-14T11:16:30+00:00journalShishi
http://use.perl.org/~Simon/journal/5641?from=rss
<p>The Perl prototype to shishi managed to match "abc" today. From here on, getting the regular expression engine part of the runtime together is a SMOP; ensuring that the parsing side of it works as well is slightly more tricky. It's baby steps (and I'm going to take a few more days off to speed things up) but I'm still very excited about what's possible.</p>Simon2002-06-13T21:22:11+00:00journalIdea fairy
http://use.perl.org/~Simon/journal/5610?from=rss
<p>Selective tainting. "Taint all filehandles, but not environment accesses." Or even, "taint this filehandle, since it's coming in from the network, but not that one, since it's the server config file and I trust it". Difficult to implement in Perl 5 without a major slowdown, I think. You'd have to split taint checking from actual tainting, for starters. But worth thinking about.</p>Simon2002-06-12T16:10:08+00:00journalGrading hack
http://use.perl.org/~Simon/journal/5601?from=rss
<tt>lynx -dump http://www.european-go.org/rating/alluk.html |<br>perl -lane '$x=(2100-$F[5])/100;<br>print "$F[2] $F[1] ($F[4]) European grade: "<br>.($x>0?"${x}k":(1-$x)."d") if $F[3] eq "Oxf";'</tt>Simon2002-06-12T08:49:03+00:00journalJohn Martyn
http://use.perl.org/~Simon/journal/5597?from=rss
<a href="http://www.grunthos.demon.co.uk/grace_and_danger.htm">Grace and Danger</a> was recorded in 1979. It was released in late 1980.<p>
Not because there were any problems with it, but because Chris Blackwell, the head of the record company, though it was too painful to release. You've not felt angst until you've heard "Baby, Please Come Home" or "Some People Are Crazy".
</p><p>
<b>Warning: Do not listen to this album alone.</b></p>Simon2002-06-11T20:55:47+00:00journalSick sick sick
http://use.perl.org/~Simon/journal/5577?from=rss
<p>Idea of the day: JIT the bytecode produced by the regexp engine. Shouldn't actually be too hard. Produce a bunch of C functions which perform each node, keep everything in registers, and use C magic to build a buffer stringing the assembly code for each function together.</p>Simon2002-06-11T12:34:04+00:00journalTeaching
http://use.perl.org/~Simon/journal/5547?from=rss
Every night before I teach, I dread the morning. But then when I get into the class and start teaching, I love it. Weird.
<p>
Tomorrow morning, I'm teaching regular expressions in the OUCS public Perl course; anyone from the University can come along and be taught basic Perl. It's a six week course of three hours a week - to give you a clue about the pace of it, we spent three hours a couple of weeks ago just on arrays. We're talking absolute beginning programmers here. Still, it's good fun.
</p><p>
I spent the day writing the course; I'm pretty much ready, although I haven't written all the notes I need - I don't have anything on substitution, say, but I'm sufficiently prepared I can make it up on the hoof. Fun.</p>Simon2002-06-10T17:24:45+00:00journalI am a veritable module machine again!
http://use.perl.org/~Simon/journal/5546?from=rss
<code>Games::Goban</code> and <code>Apache::AxKit::Language::XSP::ObjectTaglib</code> uploaded!Simon2002-06-10T16:14:44+00:00journalOverkill
http://use.perl.org/~Simon/journal/5532?from=rss
A mailbox scanner:<blockquote><div><p> <tt>#!/usr/bin/perl<br>use strict;<br>use Mail::Util qw( read_mbox );<br>use Mail::Internet;<br>use Mail::Address;<br>use Time::Duration;<br>use Date::Manip qw( ParseDate UnixDate );<br>for (map { Mail::Internet->new($_) } read_mbox("/home/simon/mail/pending")) {<br> my $when = $_->get("Date");<br> my $who = (Mail::Address->parse($_->get("From")))[0];<br> $when = time - UnixDate(ParseDate($when), "%s");<br> print "Mail received ",ago($when), " from ",$who->phrase,"\n";<br> print "Subject: ", $_->get("Subject"),"\n";<br>}</tt></p></div> </blockquote><p>Fourteen lines, six Perl modules, to summarise a mailbox. What <i>was</i> I thinking?</p>Simon2002-06-10T10:50:53+00:00journalChristdot
http://use.perl.org/~Simon/journal/5508?from=rss
<a href="http://www.christdot.org/">Slashdot for Christians.</a> I have no idea what I think of this.Simon2002-06-08T15:53:01+00:00journalDumb File Format Of The Day
http://use.perl.org/~Simon/journal/5506?from=rss
<a href="http://www.red-bean.com/sgf/">Smart Game Format</a>.
<p>
Actually, it's reasonably sane on the whole - it uses s-expressions to represent variations, and it's trivial to parse. Indeed, it's what <code>Games::Goban</code> will speak natively.
</p><p>
But I couldn't work out why I was getting weird off-by-one errors in <i>some parts</i> of my display code; indeed, everything outside the upper-left quadrant of the board. Then I worked it out.
</p><p>
This supposedly for-machine-consumption file format uses a pair of characters from 'a' to 't' to represent co-ordinates on a 19x19 board. The more alert of you will notice that 't' is not the 19th letter of the alphabet, but the 20th. That's right - it actually skips over 'i'.</p><p>
Working around this makes the code messy; I think I should ditch the idea of storing the native co-ordinates, which would have been very nice, and use numerical co-ordinates instead. Ho hum.</p>Simon2002-06-08T15:31:24+00:00journal