Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

koschei (147)


Um. Me. Iain Truskett. Can be found as either Spoon or Koschei around the place, and as Braxiatel in rare circumstances. Um. Cool. Ta.

My perl svn repository [] if you want bits of code by me. Also see [] for most of them in action.

My friends [], foes [], fans [], and freaks []. And you can see what my friends are journalling [].

And everybody's journals [] (in order of updating).

Journal of koschei (147)

Sunday August 10, 2003
09:43 AM

DateTime::Format::Builder 0.76

The uploaded file


has entered CPAN as

  file: $CPAN/authors/id/S/SP/SPOON/DateTime-Format-Builder-0.76.tar.gz
  size: 81462 bytes
   md5: b33b496586a517a405b59e6628dbecac

Changes for 0.76 (10 Aug 2003)
   - Fallthrough example and test added.
   - Quick parser added to simplify fallthrough stuff.
   - Rejigged internals to allow for on_fail argument to

This is my most complex module. Every time I change it I fear for my sanity. Thankfully these latest changes will lead to me being able to simplify a lot of the code.

09:38 AM


(original at my bliki [ghastly term])

perlreref is a quick regex reference that brings together the gist of the disparate regex docs, thus giving people a single place to look if they just want to check something quickly.

I've thrown it around on irc and on the perl documentation list and taken suggestions. I gave it to p5p, and it's now in bleadperl.

There's a HTML version and the raw pod.

  • 79572 - Announcement
    • 79720 - First onlist reply
    • 79906 - Note from Rafael saying it's in blead!
      • 79909 - My reply with amendments.
        • 79910 - Applied, with tweaks
Wednesday July 16, 2003
11:51 PM tricks

Sunday July 13, 2003
09:37 PM (not regarding the colour)

djberg96 mentioned today:

sigh...why do they do soundex matching on cpan? it's pointless

Which makes me think: If the source were available someone could write gbarr a new search, could demonstrate its use and then, hopefully, persuade gbarr to use it.

Friday April 18, 2003
07:26 AM

how many places can one register at

Well, now I'm at Advogato too. Guess I can also not maintain a regular journal there too =)

BTW: follow that link and certify me, please. I'd like to be able to at least reply to articles =)

Sunday March 23, 2003
08:29 PM

tbray's java bsearch - ruby and then perl?

It's surprising how easily and quickly Java code can be turned into Ruby code.

class Array
  def bsearch ( target )
    high = self.length
    low = -1
    while high - low > 1
      probe = (high + low) / 2
      if self[probe] > target
    high = probe
    low = probe
    if low == -1 || self[low] != target
      return -1
      return low

  def bsearch_dups ( target )
    high = self.length
    low = -1
    while high - low > 1
      probe = (high + low) / 2
      if self[probe] < target
    low = probe
    high = probe
    if high == self.length || self[high] != target
      return -1
      return high

  def range ( floor, ceiling )

    answer = []

    # work on floor
    high = self.length
    low = -1
    while high - low > 1
      probe = (high + low) / 2
      if self[probe] < floor
    low = probe
    high = probe
    answer[0] = low

    # work on ceiling
    high = self.length
    low = -1
    while high - low > 1
      probe = (high + low) / 2
      if self[probe] > ceiling
    high = probe
    low = probe
    answer[1] = high

    return answer


No doubt it could be written more clearly, but even with the basic translation it's nicer than the Java version. For a start, the routines are now methods on Arrays. Damn sensible place to keep them, although I'm sure several of the 4 readers of this post will disagree (including myself depending on the phase of the moon).

Secondly, it's type free.[1] This is a good thing.

Thirdly, think about this code in Perl. What would be written differently? Would you be tempted to have another parameter, a comparator? What would you do about the difference between comparing strings and numbers?

Enough of this for now.

[1] I'm sure there's a better, or more correct, term ('independent', 'agnostic', something), but I don't know it. Feel free to comment it.

Sunday March 09, 2003
08:35 AM

Authors from packages

No, it doesn't handle every file extension. Nor every package. Nor does it take parameters. Yes, you have to modify the source to make it do anything useful for you . No, I'm not particularly concerned. Just thought someone might be amused by it =)

For something more useful: DateTime::Format::Excel (docs).

#!/usr/bin/perl -w
use strict;
use YAML;
use PerlIO::gzip;

my $packages = do {
    my %packages;
    open my $pkgs_fh, '<:gzip',
        or die "Cannot open pkgs: $!\n";
    while (<$pkgs_fh>)
        $packages{$2} = $1 if m[ ^ \S+ \s+ \S+ \s+
        $ ]x;
    close $pkgs_fh;

print "Read the details of ".(keys %$packages)." packages.\n";

my %authors;

while (<DATA>)
    printf "%30.30s => %s\n", $_, $packages->{$_};
    push @{ $authors{ $packages->{$_} } } , $_;

print Dump(\%authors);

B-Generate-1 .06
Module-Build- 0.16
WWW-SherlockSear ch-0.14
opti mize-0.03

Monday March 03, 2003
07:08 PM

Books, books, books.

I'm a slacker. I really am. I've been working on the site for a number of months now. I'm closer to getting it to where I like it, but have some problems.

Number 1 is: page design. It's great, except for the actual book page. I've had one suggestion for an alternate design. [1] But that only affects the outside material, not the actual page content.


Suggestions welcome.


Also, there's the data front. Need lots of data in the system. We have basic details of 95 books. 8 of those also have blurbs and such. Most are categorised somehow. And I've got a mozilla bookmark folder containing another 20-30 books to be added; mental notes of another dozen.

Shame XML::Simple broke. There goes my nice 'grab details from when adding a book' feature.


Covers are another fun thing. Currently, we've misappropriated most of them. We have permission from a number of publishers to put up whatever we like, which is nice. However that still entails getting nice images. Mostly using images currently, and they're somewhat crap.


[1] Yes, the tabs don't actually work yet. Mockup rather than proof of concept.

Thursday September 26, 2002
07:47 AM

This was done just to determine something.

All will become clear, later.

Tuesday September 17, 2002
08:27 PM

Journal poster number 9

#!/usr/bin/perl -w
use strict;
use WWW::UsePerl::Journal;

my $subject = <>;
chomp $subject;
my $entry = join( '', <> );

my $j = WWW::UsePerl::Journal->new('fred');
    title => $subject,
    text => $entry,

[updated with petdance's changed]