Author: timbo
Date: Tue Sep 26 14:08:06 2006
New Revision: 7855

Added:
   dbi/trunk/ex/profile.pl
   dbi/trunk/lib/DBI/ProfileSubs.pm

Log:
Add to svn somes files that were in 1.52


Added: dbi/trunk/ex/profile.pl
==============================================================================
--- (empty file)
+++ dbi/trunk/ex/profile.pl     Tue Sep 26 14:08:06 2006
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -w
+
+use DBI;
+
+$dbh = DBI->connect('dbi:SQLite:dbname=ex_profile.db', '', '', { RaiseError => 
1 });
+
+$dbh->do("DROP TABLE IF EXISTS ex_profile");
+$dbh->do("CREATE TABLE ex_profile (a int)");
+
+ $dbh->do("INSERT INTO ex_profile (a) VALUES ($_)", undef)     for 1..100;
+#$dbh->do("INSERT INTO ex_profile (a) VALUES (?)",  undef, $_) for 1..100;
+
+my $select_sql = "SELECT a FROM ex_profile";
+
+$dbh->selectall_arrayref($select_sql);
+
+$dbh->selectall_hashref($select_sql, 'a');
+
+my $sth = $dbh->prepare($select_sql);
+$sth->execute;
+while ( @row = $sth->fetchrow_array ) {
+}
+
+
+__DATA__

Added: dbi/trunk/lib/DBI/ProfileSubs.pm
==============================================================================
--- (empty file)
+++ dbi/trunk/lib/DBI/ProfileSubs.pm    Tue Sep 26 14:08:06 2006
@@ -0,0 +1,41 @@
+package DBI::ProfileSubs;
+
+=head1 NAME
+
+DBI::ProfileSubs - Subroutines for dynamic profile Path
+
+=head1 SYNOPSIS
+
+  DBI_PROFILE='& prog.pl
+
+This is new and still experimental.
+
+=cut
+
+use strict;
+use warnings;
+
+
+# would be good to refactor these regex into separate subs or find some other
+# way to compose them in various combinations into multiple subs
+
+sub norm_std_n3 {
+    # my ($h, $method_name) = @_;
+    local $_ = $_;
+
+    s/\b\d+\b/<N>/g;             # 42 -> <N>
+    s/\b0x[0-9A-Fa-f]+\b/<N>/g;  # 0xFE -> <N>
+
+    s/'.*?'/'<S>'/g;             # single quoted strings (doesn't handle 
escapes)
+    s/".*?"/"<S>"/g;             # double quoted strings (doesn't handle 
escapes)
+
+    # convert names like log20001231 into log<N>
+    s/([a-z_]+)(\d{3,})\b/${1}<N>/ig;
+
+    # abbreviate massive "in (...)" statements and similar
+    s!((\s*<[NS]>\s*,\s*){100,})!sprintf("$2,<repeated %d 
times>",length($1)/2)!eg;
+
+    return $_;
+}
+
+1;

Reply via email to