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 ]

jkondo (7642)

  (email not shown publicly)

Journal of jkondo (7642)

Friday March 30, 2007
04:14 PM

Moved to VOX

I've moved this journal to See you at

Friday March 09, 2007
06:30 PM

DBIx::MoCo 0.07 released

I uploaded DBIx::MoCo 0.07 today.

Changes from 0.06 are as follows.

0.07  Fri Mar 9 2007
    - Added DBIx::MoCo::Schema for schema definition
    - Added count method to DBIx::MoCo
    - Removed keys method and added unique_keys method to MoCo
    - Changed primary_keys, unique_keys to get info automatically
        - Added cache_status method to DBIx::MoCo
    - Added DBIx::MoCo::Column and URI plugin for inflating columns
    - Added DBIx::MoCo::Join for joined classes
    - Added DBIx::MoCo::Readonly for read only classes.
    - Fixed problem new session will start when save_changed is called.
    - Added retrieve_by_a_or_b handler into DBIx::MoCo
    - Added descriptions to MoCo's pod.
    - Added retrieve_keys to MoCo

Tuesday February 27, 2007
04:58 PM

Text::Hatena 0.20 released.

I uploaded Text::Hatena 0.20. It's quite new version of Text::Hatena.

I rewrote the whole code using Parse::RecDescent and Regexp::Assemble. Number of modules were reduced to 2 from 47 files. Line of codes where changed from 2600 lines to 600 lines. My benchmark marked 300-400% higher performance than ver.0.16.

I also removed some syntaxes which were specific to Hatena Diary.

Now, API for parsing text were changed too. Please be careful to upgrade your
Text::Hatena to version 0.20+.

You can use Text::Hatena simply as below.

my $html = Text::Hatena->parse($text);

And, you can extend your parser like this. You can easily make your original parser which can handle some other format.

package MyParser;
use strict;
use warnings;
use base qw(Text::Hatena);

    h3 : "\n*" timestamp(?) inline(s)
    timestamp : /\d{9,10}/ '*'

sub h3 {
    my $class = shift;
    my $items = shift->{items};
    my $title = $class->expand($items->[2]);
    return if $title =~ /^\*/;
    my $ret = "<h3>$title";
    if (my $time = $items->[1]->[0]) {
        $ret .= qq|<span class="timestamp">$time</span>|;
    $ret .= "</h3>\n";

sub timestamp {
    my $class = shift;
    my $items = shift->{items};
    return $items->[0];


You can also extend inline elements like this.

    'id:([\w-]+)' => sub {
        my $mvar = shift;
        my $name = $mvar->[1];
        return qq|<a href="/$name/">id:$name</a>|;
    'd:id:([\w-]+)' => sub {
        my $mvar = shift;
        my $name = $mvar->[1];
        return qq|<a href="$name/">d:id:$name</a>|;

I'd like to get your feedback.
Monday February 12, 2007
03:17 PM

I changed the name of my model class to DBIx::MoCo again.

I changed the name of my model class to DBIx::MoCo again. I uploaded DBIx::MoCo ver. 0.06 and removed MoCo* files just now.
Thanks for suggesting me to change the name.

I also implemented cache_connection attribute in DBIx::MoCo::DataBase.

If its set to 0, DBIx::MoCo::DataBase uses DBI->connect instead of

Saturday February 03, 2007
08:31 PM

I fixed bug in MoCo and added keys accessor.

I uploaded MoCo ver 0.05 today.
I fixed a bug that cached objects are not flushed correctly when they're stored without primary keys.
I added keys accessor to MoCo and changed flush mechanism.

If you define like this,

package Entry;

and, retrieve an entry from uri,

my $e = Entry->retrieve_by_uri('http://123');

and, create a new entry.

my $e2 = Entry->create(uri => 'http://123');

The first cache, $e is flushed correctly.

(I'm still considering about the name.)

Wednesday January 31, 2007
04:00 PM

I changed the name to MoCo and released ver 0.04.

I changed the name of my model class to
It's light & fast Model Component. (it's processing now)

Also, I implemented session features today.
You can delay your update/create operation using MoCo's session.

If you call MoCo->start_session once, a session will be started and update/create queries will be delayed until the session will be ended or save method will be called expressly.

# in your web server etc..

# in your scripts
my $user = Blog::User->retrieve(123);
$user->name('jkondo'); # not saved now. changed in cache.
print $user->name; # 'jkondo'
$user->save; # update db
print Blog::User->retrieve(123)->name; # 'jkondo'

# Or, update queries will be thrown automatically after ending session.
print Blog::User->retrieve(123)->name; # 'jkontan'

Tuesday January 30, 2007
05:33 PM


I uploaded Class::Moco 0.03 today.

Class::Moco is easy to cache model component.
It provides the way to create models like Class::DBI and store objects in cache easily.

I'd like to get feedbacks.

Here is the SYNOPSIS of Class::Moco.

    # First, set up your db.
    package Blog::DataBase;
    use base qw(Class::Moco::DataBase);



    # Second, create a base class for all models.
    package Blog::TableObject;
    use base qw 'Class::Moco'; # Inherit Class::Moco



    # Third, create your models.
    package Blog::User;
    use base qw 'Blog::TableObject';

            entries => 'Blog::Entry',
            { key => 'user_id' }
            bookmarks => 'Blog::Bookmark',
            { key => 'user_id' }


    package Blog::Entry;
    use base qw 'Blog::TableObject';

            user => 'Blog::User',
            { key => 'user_id' }
            bookmarks => 'Blog::Bookmark',
            { key => 'entry_id' }


    package Blog::Bookmark;
    use base qw 'Blog::TableObject';

            user => 'Blog::User',
            { key => 'user_id' }
            entry => 'Blog::Entry',
            { key => 'entry_id' }


    # Now, You can use some methods same as in Class::DBI.
    # And, all objects are stored in cache automatically.
    my $user = Blog::User->retrieve(user_id => 123);
    print $user->name;
    $user->name('jkontan'); # update db immediately
    print $user->name; # jkontan

    my $user2 = Blog::User->retrieve(user_id => 123);
    # $user is same as $user2!

    # You can easily get has_many objects array.
    my $entries = $user->entries;
    my $entries2 = $user->entries;
    # $entries is same reference as $entries2!
    my $entry = $entries->first; # isa Blog::Entry
    print $entry->title; # you can use methods in Entry class.

        user_id => 123,
        title => 'new entry!',
    # $user->entries will be flushed automatically.
    my $entries3 = $user->entries;
    # $entries3 isnt $entries!

    print ($posts1->[-1] eq $posts2->[-1]); # 1
    print ($posts1->[-1] eq $posts3->[-1]); # 1
    # It's same instance!

12:32 AM

Hello Perl

It's my first journal.