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 ]

ChrisDolan (2855)

  (email not shown publicly)

Journal of ChrisDolan (2855)

Sunday February 14, 2010
09:59 PM

Devel::Symdump + Compress::Zlib crash


The following is a known bug that crashes Perl 5.10.0 (solved for 5.10.1 via Perl RT#52740)

perl -MCompress::Zlib -MDevel::Symdump -e'Devel::Symdump->rnew'

Does anyone know of a workaround? I want my software to work on 5.10.0 because that's what Apple ships with Snow Leopard. I don't want to use the 5.8.9 that ships with SL because I want 64-bit.

See also CPAN RT#43675 - Segfault bug in rnew->packages from Test::Class+Moose+Test::WWW::Mechanize::Catalyst

Thursday August 13, 2009
09:33 PM

[non-perl] Hacking iPhoto via SQLite

(a very off-topic SQL exercise follows...)

Apple's iPhoto 2009 has a very cool face recognition feature where it will show you faces and prompt you to enter names. When it finds resemblances, it will suggest names for you to confirm or reject.

When it's wrong, it makes for funny little screenshots you can send to friends: "Haha, cute girl! You look like an older heavier man!"

But once you reject the match, you can't undo or get it back in any other way. Luckily, iPhoto stores ALL of its metadata in a collection of SQLite databases. So, in the particular case that I linked above I was able to undo by telling the database not to ignore the marked mismatches from IMG_0095.JPG:

% osascript -e 'tell application "iPhoto" to quit'
% cd "Pictures/iPhoto Library"
% sqlite3 iPhotoMain.db
sqlite> select photoKey,relativePath from SqFileImage,SqFileInfo where sqFileInfo=SqFileInfo.primaryKey and relativePath like '%IMG_0095.JPG';
110|Data/2003/Roll 15/IMG_0095.jpg
110|Originals/2003/Roll 15/IMG_0095.JPG
3666|Data/2006/Apr 25, 2006/IMG_0095.jpg
3666|Originals/2006/Apr 25, 2006/IMG_0095.JPG
sqlite> .exit
% sqlite3 face.db
sqlite> update similar_faces set ignore=0 where image_key=110;
sqlite> .exit
% open -a

Sunday July 26, 2009
02:08 PM

[non-perl] mdfind vs. locate

I've used the "locate" command for many, many years on various POSIX systems. It's a very fast search for filenames containing the specified string on your machine.

Here's a Mac command that simulates "locate" using the Spotlight database:

mdfind "kMDItemFSName == '*$1*'"

It's not as fast as locate, but it is always up to date (as opposed to locate, which relies on cron to reindex the disk periodically). As anyone can guess from the syntax, it's also very flexible. To find all files that originated as email attachments from my friend Glenn, for example, I can do:

mdfind "kMDItemWhereFroms == '**'"

Or to find all files bigger than about a gigabyte:

mdfind "kMDItemFSSize > 1000000000"

(the WhereFroms search is fast and the size search is dramatically slower, maybe because all files have sizes but not many have kMDItemWhereFroms metadata)

To get a list of the supported keywords, type "mdimport -A"

Update: I found the Spotlight query syntax to be useful

Saturday July 04, 2009
01:12 PM

Copy protection: users vs. developers

A few weeks ago, LWN ran an article about the Okular PDF viewer which enforces copy protection as specified in the PDF specification. The LWN editor and several commenters complained about this restriction to their freedom. I have three comments on that topic:

1) As a PDF implementor myself, I chose to implement the PDF copy protection features just as Okular did. I did this because Adobe's license agreement to download the spec insisted that I do not willfully violate the spec. I agreed to those terms and so I have ignored all requests to disable said protection in my own library.

2) It's open source. Anybody can trivially turn off the copy protection and recompile (my library is Perl, so you don't even need to recompile). If they do, then they can bear the responsibility for violating the spec.

3) Do you ever hear people complaining about permissions in the tar file utility? Even GNU tar implements file access controls as specified in the tar file. If I untar a file which is -r--r--r-- or even ---x--x--x, is that a violation of my rights? I say not. It's a minor inconvenience at worst and an excellent safety precaution at best. Nobody's beating a drum to remove copy protection features from tar.

The copy protection worth fighting against is the kind that can take away your current rights at some unspecified future time (like what happened when Google Video or Walmart music shut down their DRM servers)

Thursday July 02, 2009
09:24 PM

Coding Horror

Jeff Atwood is the best tech blogger in the world, in my opinion. And his most recent post contains my nominee for the quote of the year:

Open source software only comes in one edition: awesome.

Thursday February 12, 2009
11:04 PM

Rakudo improves!

I haven't really been working on features for my Perl 6 PDF grammar very much, but I have been using it as a tool to follow improvements in the Rakudo implementation of Perl 6.

This week, I went through all of the PDF code and looked for comments I wrote for myself about workarounds for incomplete parts of Rakudo. The exciting news is that I was able to remove about half of my workarounds this week. Considering that most of the rest of the annoyances are features that are on the near-term roadmap (mainly, PGE refactoring), I consider this to be superb progress.

Bravo, Perl 6 developers!

I made a contribution of my own, too, which has made me absurdly happy out of proportion to the size of the patch. I implemented 'make' from S05. This builtin function is shorthand for the following:

# Equivalent code:
  make $value;

This, along with other simplifications allowed me to shave about half of the lines of PDF::Grammar::Actions while improving readability. Yay!

Wednesday February 11, 2009
12:47 AM

Perk moved to github

Today I moved Perk (a Java compiler targeting Parrot) to github. I do not intend to maintain the SVN repository at googlecode. Sorry for the churn, but better now than later...

I am working on converting the to be real Perl 6 instead of NQP. I submitted a prerequisite patch to Rakudo to support that (implement the 'make' builtin). But I'm getting mysterious runtime failures with basic PIR.

If you want to try Perl 6, just edit one line of the Perk Makefile to change "ACTION_COMPILER=nqp.pbc" to "ACTION_COMPILER=perl6.pbc".

Once I get that to work, I'll probably port perk.pir to Then we'll see about implementing more of the actions.

Thursday February 05, 2009
10:57 PM

Frozen Perl talk: Perl 6 grammars

I'm headed to Frozen Perl tomorrow. My talk is titled Using Rakudo Grammars, but it ended up being more about Perl 6 than specifically the Parrot/Rakudo implementation.

I'm looking forward to the hackathon Sunday. I'm thinking that I'd like to work on enabling any language's PCT to be implemented in Rakudo instead of NQP. Patrick Michaud mentioned a few blockers in IRC, so I'm hoping to work on those.

Wednesday January 14, 2009
10:40 PM

Perk: an implementation of Java language on Parrot

I moved my Java parsing experiment from my own SVN to the Squawk project. Squawk is intended to Parrot-based languages that are too small or immature to live on their own.

I chose the name "Perk" for my implementation to avoid any risk of Java trademarks. It's short, it reminds you of caffeine, and it's only one letter away from Perl.

If this project doesn't wither on the vine (a very real possibility, I admit) then I hope it will be source code compatible with basic Java. I have no intention of any interoperability with Java bytecode or the Java VM.

The source code is easily browsable. If anyone is interested in participating, I welcome the company. There's no way I'm going to make more than a dent in this project by myself.

Tuesday January 13, 2009
10:29 PM

Regex for floating hex

A couple days ago I wrote about Java syntax for hexadecimal representation of floating point numbers like this:


Here are the Perl 6 grammar snippets I put together to parse this. Easy!

token HexLiteral {
  '0' ['x'|'X'] [
     | '.' <HexDigit>+ <HexExponent>? <FloatTypeSuffix>?
     | <HexDigit>+ [
         | '.' <HexDigit>* <HexExponent>? <FloatTypeSuffix>?
         | <IntegerTypeSuffix>?
token HexDigit { [\d|<[a..f]>|<[A..F]>] }
token HexExponent { ['p'|'P'] ['+'|'-']? \d+ }
token FloatTypeSuffix { 'f'|'F'|'d'|'D' }