marcel's Journal marcel's use Perl Journal en-us use 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:20:57+00:00 pudge Technology hourly 1 1970-01-01T00:00+00:00 marcel's Journal Blosxom plugin for Sensei's Library In <a href="">my blog</a> about the game of Go I'm using <a href="">blosxom</a>. Since I'm likely to refer to <a href="">Sensei's Library</a>, the expansive Wiki for Go players, quite a bit, I wrote a blosxom plugin that makes it easy to create links to Sensei's Library without having to construct the URLs and link markup manually. <p> The plugin is available for <a href="/software/plugins/senseis_library">download</a>. Here is how to use it: </p><p> A link in a story like this: </p><p> <code>&lt;SL:RecentChanges&gt;latest updates&lt;/SL&gt;</code> </p><p> is turned into a link like this: </p><p> <code>&lt;a href=""&gt;latest updates&lt;/a&gt;</code> </p><p> You don't need to escape non-alphanumeric characters in topics. For example, to link to a subpage of a topic, use: </p><p> <code>&lt;SL:BenjaminTeuber/GuideToBecomeStrong&gt;...&lt;/SL&gt;</code> </p><p> If you don't provide a topic to link to in the <code>&lt;SL&gt;</code> tag, the link text is wikified and used instead. Therefore, the same result as above can be obtained by </p><p> <code>&lt;SL&gt;Recent Changes&lt;/SL&gt;</code> </p><p> As in normal HTML, the tag isn't case sensitive, so you could also use <code>&lt;sl&gt;</code>. </p> marcel 2006-02-09T13:52:26+00:00 tools Class::MethodMaker::Util deleted <p>I've scheduled Class::MethodMaker::Util for deletion from CPAN, as the author of Class::MethodMaker has folded the new method generators into his module, which is a much better solution anyway.</p> marcel 2003-08-25T15:32:30+00:00 journal Weird spam <p>This morning I received a weird message. Doesn't look like the usual spam, but I do think it is spam...</p><p>&gt; Date: Thu, 31 Jul 2003 09:47:14 +0200<br>&gt; From: "Klingenstijn14" <br>&gt; To: <br>&gt; Subject: a question<br>&gt;<br>&gt; Dear Marcel,<br>&gt;<br>&gt; During my search tripp I found you on my route and I am wondering if<br>&gt; you're willed to answer me.<br>&gt;<br>&gt; I met somebody at the internet but I do not feel really safe to that<br>&gt; person. First I had permission to support him and got her fixed IP-address<br>&gt; but seems there's another ip address.<br>&gt;<br>&gt; Can you tell me how I can find out that person still is at it's<br>&gt; original location?<br>&gt;<br>&gt; Thanks so far.<br>&gt;<br>&gt; Perry</p> marcel 2003-07-31T08:32:29+00:00 journal Class::Null vs Class::BlackHole vs Class::Void <p>Oh dear. Before uploading or even writing Class::Null, as with any other class, I've searched CPAN for a module that would do what I needed. But Sean Burke's Class::BlackHole somehow escaped me. It seems to do pretty much what Class::Null does, except that Class::Null is even more minimalistic. Maybe I just scanned the list for things like 'Null' because I was thinking of the Null pattern...</p><p>And Class::Void isn't too dissimilar either. Oh well.</p> marcel 2002-09-03T07:44:47+00:00 journal Test::Distribution 1.02 (nee Comprehensive) <p>Andy Lester suggested to rename this module to Test::Distribution, which sounds a lot better than the old name (and might be more acceptable than "Test::Fascist" - sorry Dave<nobr> <wbr></nobr>:)). I've also updated the documentation with proper credits this time.</p><p>And Matt Sergeant asked for an option to specify only some of the functionality, e.g. only testing pod or only testing 'use'. So that's gone in as well.</p><p>Nice to see Open Source working; also read Andy Lester's journal entry at</p><p>I'm toying with the idea of adding an 'exports' test option which would go through all of your module's exports (@EXPORT and @EXPORT_OK) after loading it and making sure that there is a test script for each of the exported symbols. *That* would have been really fascist, but now that it's possible to turn certain functionality off...</p> marcel 2002-09-03T07:21:19+00:00 journal DBIx::Lookup::Field 1.2 <p>And another release today. DBIx::Lookup::Field 1.2 adds dbi_lookup_field_with_reverse(), which in addition to the lookup hash, also gives you the reverse hash. Just a small convenience function.</p><p>Yes, I'm aware of what will happen if you have the same value several times in your original lookup hash. Yes, the function name is pretty long.</p> marcel 2002-09-02T16:43:52+00:00 journal Test::Comprehensive 1.00 <p>Here's a little testing aid. It was inspired by brian d foy (</p><p> &nbsp; &nbsp; $ cat t/01comprehensive.t<br> &nbsp; &nbsp; use Test::Comprehensive;<br> &nbsp; &nbsp; $ make test<nobr> <wbr></nobr>...</p><p>When using this module in a test script, it goes through all the modules in your distribution, checks their POD, checks that they compile ok and checks that they all define the same $VERSION.</p><p>It defines its own testing plan, so you can't use it in conjunction with other Test::* modules in the same file. Therefore it's recommended that you just create a one-line test script as shown above.</p> marcel 2002-09-02T16:16:27+00:00 journal Devel::SearchINC 1.2 <p>I've updated the module to use Test::More, added a debugging option and resolved a small but somewhat irrelevant bug. And documented it, of course. After changing email accounts several times, I'll only use my mail address in module docs from now on. This makes it much easier to redirect where the mails go to via the PAUSE web interface.</p> marcel 2002-09-02T09:38:08+00:00 journal Exporter::Simple 1.00 <p>At last I've updated Exporter::Simple. With perl 5.6.0, there were no 'our' attributes, and exporting lexicals involved dealing with Filter::Simple and PadWalker and other nastiness. And it made the Exporter::Simple code horribly complicated.</p><p>So with perl 5.8.0 out I did a total rewrite. export globals, nor do we need to export lexicals (which was a weird concept anyway). So there's no need for Filter::Simple and PadWalker or any of the ugly workarounds that introduced. And once it occurred to me that Exporter::Simple could just subclass Exporter, and modules wanting to use Exporter::Simple could subclass it, things were a lot easier. Now using the attributes will populate the exporting package's @EXPORT, @EXPORT_OK and %EXPORT_TAGS direcltly, and we let Exporter have its way (with a few slight modifications).</p><p>It's beautiful. And more proof of the old adage "if it's too complicated, there's probably something wrong with it" - when it's right, it's rather simple and elegant and things easily fall into place.</p> marcel 2002-09-02T09:32:07+00:00 journal Class::Null <a href="">Class::Null</a>, on its way to CPAN, implements the Null Class design pattern. The code is exceedingly simple, but the manpage explains the concept in some detail. This class is a by-product of the design for a class system for one of the projects I'm working on. The study of design patterns is actually pretty interesting. Object-Oriented Analysis and Design (OOA and OOD) should be rewarding topics to work on (both intellectually and financially). And it's a chance to show people how much more elegant that pattern could be implemented if they'd just use Perl... marcel 2002-08-16T17:01:36+00:00 journal Karaoke Streaming Server <p>Converging Technologies idea: A karaoke streaming server. Just streams text in appropriate intervals.</p> marcel 2002-07-26T14:28:17+00:00 journal Full-screen movies with Quicktime <p>The QuickTime Player Applescript Dictionary reveals that the player can indeed play movies at full-screen, so you don't have to get QuickTime Pro for just that. Here's a program that lets you do it from the command-line.</p><p>#!/usr/bin/perl</p><p>use warnings;<br>use strict;<br>use File::Spec;</p><p>my $movie = shift || die "usage: $0 movie\n";<br>my $path = File::Spec-&gt;rel2abs($movie);</p><p>my $script = EOAS;<br>set thefile to get POSIX file "$path"<br>tell application "QuickTime Player"<br> &nbsp; &nbsp; &nbsp; &nbsp; activate<br> &nbsp; &nbsp; &nbsp; &nbsp; open thefile<br> &nbsp; &nbsp; &nbsp; &nbsp; present movie 1 scale screen<br>end tell<br>EOAS</p><p>exec '/usr/bin/osascript', '-e', $script;<br>die "can't exec osascript: $?";</p> marcel 2002-07-23T13:53:43+00:00 journal SSH authentication <p>I just got fed up with having to enter the password for ssh connections time and again. Of course, it's a simple matter of copying a few files and setting a few permissions, but I just can't remember the exact things to do. So here you go: just create a key with</p><p> &nbsp; &nbsp; &nbsp; &nbsp; ssh-keygen -t dsa</p><p>and run this script:</p><p>#!/bin/sh<br># - create remote hive (well, RSA authentication).<br># $1 needs to be 'user@host'. Need to enter password two or three times.</p><p>echo 'Creating remote<nobr> <wbr></nobr>.ssh directory...'<br>ssh $1 'mkdir -p ~/.ssh &amp;&amp; chmod 700 ~/.ssh'</p><p>if [ -f ~/.ssh/ ] ; then<br> &nbsp; &nbsp; &nbsp; &nbsp; echo 'Transferring -&gt; known_hosts...'<br> &nbsp; &nbsp; &nbsp; &nbsp; scp ~/.ssh/ $1:~/.ssh/known_hosts<br>fi</p><p>if [ -f ~/.ssh/ ] ; then<br> &nbsp; &nbsp; &nbsp; &nbsp; echo 'Transferring -&gt; authorized_keys2...'<br> &nbsp; &nbsp; &nbsp; &nbsp; scp ~/.ssh/ $1:~/.ssh/authorized_keys2<br>fi</p><p>echo 'Setting permissions on public keys...'<br>ssh $1 'chmod 600 ~/.ssh/*'</p> marcel 2002-07-23T13:02:15+00:00 journal Personal Call Stack <p>I need a personal call stack. You want to do X. But to accomplish that, you need to do Y. To be able to do Y, you first need to do Z. When you've finished doing Z, you've probably forgotten about X, namely why you were doing Y and Z in the first place. That is, if you even remember Y. In short, I need a call stack. And I will not support continuations.</p> marcel 2002-07-23T12:43:58+00:00 journal OS X talk <p>Discussions about OS X in the last few days mainly seem to center around two topics: the case-insensitivity of HFS+ and a stoned girl named Ellen Feiss.</p> marcel 2002-07-23T12:43:13+00:00 journal spoken news <p>Hear your favourite RSS newsfeeds: Take some LWP, a little XML::RSS and season with command-line driven AppleScript.</p><p>#!/usr/bin/perl</p><p>use warnings;<br>use strict;<br>use XML::RSS;<br>use LWP::Simple;<br>$|++;</p><p>my %news = (<br> &nbsp; &nbsp; &nbsp; &nbsp; slashdot =&gt; "",<br> &nbsp; &nbsp; &nbsp; &nbsp; useperl =&gt; "",<br>);</p><p>my $key = shift || die "usage: $0 key\n";<br>die "unknown key\n" unless exists $news{$key};</p><p>my $rss = XML::RSS-&gt;new or die "can't create XML::RSS?";<br>eval { $rss-&gt;parse(get( $news{$key} )) } and not $@<br> &nbsp; &nbsp; &nbsp; &nbsp; or die "cannot get or parse content: $@";</p><p>for my $item (@{$rss-&gt;{items}}) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; my $title = $item-&gt;{title};<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; my $spoken = prepare_spoken($title);;</p><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print "title: \n";<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print "spoken: \n\n";<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; system('/usr/bin/osascript', '-e', sprintf q!say "%s"!, $spoken)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; == 0 or die "can't speak '$spoken': $?";<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sleep(1);<br>}</p><p>sub prepare_spoken {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; local $_ = shift;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $_ = lc;</p><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s/\.NET/ dot net<nobr> <wbr></nobr>/gi;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s/U\.S\./ U S<nobr> <wbr></nobr>/gi;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s/mozilla/ mo zilla<nobr> <wbr></nobr>/gi;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s/AMD's/ AMDs<nobr> <wbr></nobr>/gi;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s/yapc/ yapsee<nobr> <wbr></nobr>/gi;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s/bsd/ BSD<nobr> <wbr></nobr>/gi;</p><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s/(\d+)-/ $1<nobr> <wbr></nobr>/gi;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s/(?=\S)\.(?=\S)/ dot<nobr> <wbr></nobr>/gi;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s/(?=\.)/<nobr> <wbr></nobr>/g;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y/"()//d;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $_<br>}</p><p>__END__</p><p>Note that prepare_spoken is rather primitive; some more general rules would be appreciated. Send suggestions to</p> marcel 2002-07-23T12:29:19+00:00 journal