Index: lang/perl/DBIx-Printf/tags/0.06/t/00base.t
===================================================================
--- lang/perl/DBIx-Printf/tags/0.06/t/00base.t (revision 360)
+++ lang/perl/DBIx-Printf/tags/0.06/t/00base.t (revision 360)
@@ -0,0 +1,43 @@
+use strict;
+use warnings;
+
+use Test::More tests => 20;
+
+BEGIN { use_ok('DBIx::Printf'); }
+
+my $dbh = DBI->connect('DBI:Mock:', '', '');
+
+is($dbh->printf('select 1'), 'select 1', 'no args');
+is($dbh->printf('select %%s'), 'select %s', '%% -> %');
+is($dbh->printf('select %%%d', 1), 'select %1', '%%%s -> %(string)');
+
+is($dbh->printf('select %d', 1), 'select 1', 'single %d');
+is($dbh->printf('select %d', "1.3' or 1"), 'select 1', '%d with garbage');
+is($dbh->printf('select %d', ''), 'select 0', '%d with empty string');
+is($dbh->printf('select %d', 'abc'), 'select 0', '%d with not a number at all');
+
+is($dbh->printf('select %f', 1), 'select 1', 'single %f');
+is($dbh->printf('select %f', 1.3e1), 'select 13', 'single %f given a fp');
+is($dbh->printf('select %f', '1.3e1'), 'select 13', 'single %f given a fp str');
+is($dbh->printf('select %f', "'or 1"), 'select 0', 'single %f given a garbage');
+
+is($dbh->printf('select %s', "don't"), "select 'don''t'", '%s');
+
+is($dbh->printf('select %t', "don't"), "select don't", '%t');
+
+is($dbh->printf('select %d,%d,%d', 1, 2, 3), 'select 1,2,3', 'multiple args');
+
+is($dbh->printf('select 1 like %like()'), "select 1 like ''", 'empty %like');
+is($dbh->printf('select 1 like %like(%s%%)', 'a'), "select 1 like 'a%'", '%like');
+is($dbh->printf('select 1 like %like(%s%%)', "%a_b'"), "select 1 like '\\%a\\_b''%'", '%like escape check');
+
+undef $@;
+eval {
+    $dbh->printf('select 1', 1);
+};
+ok($@, 'too many parameters');
+undef $@;
+eval {
+    $dbh->printf('select %d');
+};
+ok($@, 'too few parameters');
Index: lang/perl/DBIx-Printf/tags/0.06/lib/DBIx/Printf.pm
===================================================================
--- lang/perl/DBIx-Printf/tags/0.06/lib/DBIx/Printf.pm (revision 3361)
+++ lang/perl/DBIx-Printf/tags/0.06/lib/DBIx/Printf.pm (revision 3361)
@@ -0,0 +1,137 @@
+use strict;
+use warnings;
+
+use DBI;
+
+package main;
+
+sub DBI::db::printf {
+    my ($dbh, $fmt, @params) = @_;
+    
+    my $sql = DBIx::Printf::_printf($dbh, $fmt, \@params);
+    die "too many parameters\n" if @params;
+    $sql;
+}
+
+package DBIx::Printf;
+
+our $VERSION = 0.06;
+
+sub _printf {
+    my ($dbh, $fmt, $params, $in_like) = @_;
+    
+    $fmt =~ s/\%(?:([dfst\%])|like\((.*?)\))/
+        _printf_quote({
+            dbh      => $dbh,
+            params   => $params,
+            type     => $1 || 'like',
+            like_fmt => $2,
+            in_like  => $in_like,
+        })
+            /eg;
+    $fmt;
+}
+
+sub _printf_quote {
+    my $in = shift;
+    my $out;
+    
+    if ($in->{type} eq '%') {
+        return '%';
+    } elsif ($in->{type} eq 'like') {
+        return "'"
+            . _printf($in->{dbh}, $in->{like_fmt}, $in->{params}, 1)
+                . "'";
+    }
+    
+    return _printf_quote_simple(
+        $in->{dbh}, $in->{type}, $in->{params}, $in->{in_like}
+    );
+}
+
+sub _printf_quote_simple {
+    no warnings;
+    my ($dbh, $type, $params, $in_like) = @_;
+    
+    die "too few parameters\n" unless @$params;
+    my $param = shift @$params;
+    
+    if ($type eq 'd') {
+        $param = int($param);
+    } elsif ($type eq 'f') {
+        $param = $param + 0;
+    } elsif ($type eq 'l') {
+        $param = s/[\%_]/\\$1/g;
+        $param = $dbh->quote($param); # be paranoiac, use DBI::db::quote
+        $param =~ s/^'(.*)'$/$1/s
+            or die "unexpected quote char used: $param\n";
+    } elsif ($type eq 's') {
+        if ($in_like) {
+            $param =~ s/[%_]/\\$&/g;
+        }
+        $param = $dbh->quote($param);
+        if ($in_like) {
+            $param =~ s/^'(.*)'$/$1/s
+                or die "unexpected quote char: $param\n";
+        }
+    } elsif ($type eq 't') {
+        # pass thru
+    } else {
+        die "unexpected type: $type\n";
+    }
+    
+    $param;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+DBIx::Printf - A printf-style prepared statement
+
+=head1 SYNOPSIS
+
+  use DBIx::Printf;
+
+  my $sql = $dbh->printf(
+      'select * from t where str=%s or int=%d or float=%f',
+      'string',
+      1,
+      1.1e1);
+
+=head1 DESCRIPTION
+
+C<DBIx::Printf> is a printf-style prepared statement.  It adds a C<printf> method to DBI::db package.
+
+=head1 METHODS
+
+=head2 printf(stmt, [values])
+
+Builds a SQL statement from given statement with placeholders and values.  Following placeholders are supported.
+
+  %d         - integer
+  %f         - floating point
+  %s         - string
+  %t         - do not quote, pass thru
+  %like(fmt) - formats and quotes a string for like expression
+
+=head3 %like example
+
+Below is an example of using the %%like placeholder.  Since metacharacters of supplied parameters are escaped, the example would always by a prefix search.
+
+  $dbh->printf('select * from t where name like %like(%s%%)', $name);
+
+
+=head1 AUTHOR
+
+Copyright (c) 2007 Kazuho Oku  All rights reserved.
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
+
+See http://www.perl.com/perl/misc/Artistic.html
+
+=cut
Index: lang/perl/DBIx-Printf/tags/0.06/Makefile.PL
===================================================================
--- lang/perl/DBIx-Printf/tags/0.06/Makefile.PL (revision 3361)
+++ lang/perl/DBIx-Printf/tags/0.06/Makefile.PL (revision 3361)
@@ -0,0 +1,16 @@
+use inc::Module::Install;
+
+name('DBIx-Printf');
+author('Kazuho Oku');
+version_from('lib/DBIx/Printf.pm');
+abstract_from('lib/DBIx/Printf.pm');
+license('perl');
+
+requires('DBI');
+
+build_requires('DBD::Mock');
+
+auto_include;
+auto_install;
+
+WriteAll;
Index: lang/perl/DBIx-Printf/tags/0.06/Changes
===================================================================
--- lang/perl/DBIx-Printf/tags/0.06/Changes (revision 9300)
+++ lang/perl/DBIx-Printf/tags/0.06/Changes (revision 9300)
@@ -0,0 +1,21 @@
+Revision history for Perl extension DBIx::Printf.
+
+0.06  Thu Dec 20 18:08:42 2007
+        - Change from ExtUtils::MakeMaker to Module::Install
+        - Fixed build dependency (add DBD::Mock)
+
+0.05  Thu Oct 04 13:55:00 2007
+        - added %t (passthru) placeholder
+        - added %like(fmt) placeholder
+
+0.04  Sat Sep 29 05:40:00 2007
+        - move to DBIx namespace
+ 
+0.03  Fri Sep 28 14:20:00 2007
+        - adjust declaration to pass CPAN indexer
+
+0.02  Fri Sep 28 14:10:00 2007
+        - fix mishandling of %%
+
+0.01  Fri Sep 28 09:16:00 2007
+        - initial version
Index: lang/perl/DBIx-Printf/tags/0.06/README
===================================================================
--- lang/perl/DBIx-Printf/tags/0.06/README (revision 304)
+++ lang/perl/DBIx-Printf/tags/0.06/README (revision 304)
@@ -0,0 +1,21 @@
+DBIx-Printf version 0.01
+=======================
+
+INSTALLATION
+
+To install this module type the following:
+
+   perl Makefile.PL
+   make
+   make test
+   make install
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2007 Kazuho Oku
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.8.6 or,
+at your option, any later version of Perl 5 you may have available.
+
+
