Index: /trunk/ippTools/configure.ac
===================================================================
--- /trunk/ippTools/configure.ac	(revision 12085)
+++ /trunk/ippTools/configure.ac	(revision 12086)
@@ -47,4 +47,10 @@
 fi
 
+dnl check for perl
+AC_PATH_PROG([PERL], [perl], [missing])
+if test "$PERL" = "missing" ; then
+  AC_MSG_ERROR([perl is required])
+fi
+
 IPP_STDOPTS
 CFLAGS="${CFLAGS=} -Wall -Werror -std=c99"
Index: /trunk/ippTools/share/regtool_find_unprocessed_exp.sql
===================================================================
--- /trunk/ippTools/share/regtool_find_unprocessed_exp.sql	(revision 12086)
+++ /trunk/ippTools/share/regtool_find_unprocessed_exp.sql	(revision 12086)
@@ -0,0 +1,15 @@
+SELECT
+   newExp.*
+FROM newExp
+LEFT JOIN newImfile
+   USING(exp_tag)
+LEFT JOIN rawExp
+   USING(exp_tag)
+WHERE
+    newExp.exp_tag IS NOT NULL
+    AND newImfile.exp_tag IS NULL
+    AND rawExp.exp_tag IS NULL
+    AND newExp.imfiles =
+    (SELECT COUNT(exp_tag) FROM rawImfile
+        WHERE rawImfile.exp_tag = newExp.exp_tag)
+    AND newExp.exp_tag = '%s'
Index: /trunk/ippTools/share/regtool_find_unprocessed_imfile.sql
===================================================================
--- /trunk/ippTools/share/regtool_find_unprocessed_imfile.sql	(revision 12086)
+++ /trunk/ippTools/share/regtool_find_unprocessed_imfile.sql	(revision 12086)
@@ -0,0 +1,8 @@
+SELECT
+    *
+FROM
+    (SELECT newImfile.* FROM newImfile
+        LEFT JOIN newExp USING(exp_tag)
+        LEFT JOIN rawExp USING(exp_tag)
+        WHERE newExp.exp_tag IS NOT NULL
+        AND rawExp.exp_tag IS NULL) as Foo
Index: /trunk/ippTools/share/regtool_pendingexp.sql
===================================================================
--- /trunk/ippTools/share/regtool_pendingexp.sql	(revision 12086)
+++ /trunk/ippTools/share/regtool_pendingexp.sql	(revision 12086)
@@ -0,0 +1,15 @@
+SELECT
+    newExp.*
+FROM newExp
+LEFT JOIN newImfile
+    USING(exp_tag)
+LEFT JOIN rawExp
+    USING(exp_tag)
+WHERE
+    newImfile.exp_tag IS NULL
+    AND rawExp.exp_tag IS NULL
+    AND newExp.imfiles =
+    (SELECT COUNT(exp_tag) FROM rawImfile
+        WHERE
+            rawImfile.exp_tag = newExp.exp_tag
+            AND rawImfile.fault = 0)
Index: /trunk/ippTools/share/regtool_pendingimfile.sql
===================================================================
--- /trunk/ippTools/share/regtool_pendingimfile.sql	(revision 12086)
+++ /trunk/ippTools/share/regtool_pendingimfile.sql	(revision 12086)
@@ -0,0 +1,11 @@
+SELECT
+   newImfile.*,
+   newExp.workdir
+FROM newImfile
+LEFT JOIN newExp
+    USING(exp_tag)
+LEFT JOIN rawExp
+    USING(exp_tag)
+WHERE
+    newExp.exp_tag is NOT NULL
+    AND rawExp.exp_tag IS NULL
Index: /trunk/ippTools/share/regtool_processedimfile.sql
===================================================================
--- /trunk/ippTools/share/regtool_processedimfile.sql	(revision 12086)
+++ /trunk/ippTools/share/regtool_processedimfile.sql	(revision 12086)
@@ -0,0 +1,5 @@
+SELECT
+    *
+FROM rawImfile
+-- bogus conditional so there is a where clause to append to
+WHERE rawImfile.exp_tag is NOT NULL
Index: /trunk/ippTools/src/regtool.c
===================================================================
--- /trunk/ippTools/src/regtool.c	(revision 12085)
+++ /trunk/ippTools/src/regtool.c	(revision 12086)
@@ -25,4 +25,5 @@
 
 #include "pxtools.h"
+#include "pxdata.h"
 #include "regtool.h"
 
@@ -112,17 +113,9 @@
     // that should be checked for
 
-    psString query = psStringCopy(
-        "SELECT\n"
-        "   newImfile.*,\n"
-        "   newExp.workdir\n"
-        " FROM newImfile\n"
-        " LEFT JOIN newExp\n"
-        "   USING(exp_tag)\n"
-        " LEFT JOIN rawExp\n"
-        "   USING(exp_tag)\n"
-        " WHERE\n"
-        "   newExp.exp_tag is NOT NULL\n"
-        "   AND rawExp.exp_tag IS NULL\n"
-    );
+    psString query = pxDataGet("regtool_pendingimfile.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statment");
+        return false;
+    }
 
     // treat limit == 0 as "no limit"
@@ -184,16 +177,9 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // XXX search by the whole frame some imfiles without a newExp don't get
-    // processed -- this may not be the correct thing to do
-    psString query = psStringCopy(
-        "SELECT\n"
-        "   *\n"
-        " FROM\n"
-        "   (SELECT newImfile.* FROM newImfile\n"
-        "       LEFT JOIN newExp USING(exp_tag)\n"
-        "       LEFT JOIN rawExp USING(exp_tag)\n"
-        "       WHERE newExp.exp_tag IS NOT NULL\n"
-        "       AND rawExp.exp_tag IS NULL) as Foo\n"
-        ); // WHERE class is generated from exp_tag, class, & class_id
+    psString query = pxDataGet("regtool_find_unprocessed_imfile.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statment");
+        return false;
+    }
 
     {
@@ -363,11 +349,9 @@
     }
 
-    // find all rawImfiles matching the default query
-    psString query = psStringCopy( 
-        "SELECT\n"
-        "   *\n"
-        " FROM rawImfile\n"
-        " WHERE rawImfile.exp_tag is NOT NULL\n" //bogus conditional so there is a where clause to append to
-    );
+    psString query = pxDataGet("regtool_processedimfile.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statment");
+        return false;
+    }
 
     if (config->where) {
@@ -479,22 +463,9 @@
     // have ALL of their imfiles in rawImfile (by count)
     // and have no associated imfiles left in newImfile
-
-    psString query = psStringCopy(
-        "SELECT"
-        "   newExp.*"
-        " FROM newExp"
-        " LEFT JOIN newImfile"
-        "   USING(exp_tag)"
-        " LEFT JOIN rawExp"
-        "   USING(exp_tag)"
-        " WHERE"
-        "   newImfile.exp_tag IS NULL"
-        "   AND rawExp.exp_tag IS NULL"
-        "   AND newExp.imfiles ="
-        "   (SELECT COUNT(exp_tag) FROM rawImfile"
-        "       WHERE"
-        "           rawImfile.exp_tag = newExp.exp_tag"
-        "           AND rawImfile.fault = 0)"
-    );
+    psString query = pxDataGet("regtool_pendingexp.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statment");
+        return false;
+    }
 
     // treat limit == 0 as "no limit"
@@ -578,20 +549,9 @@
     }
 
-   char *query = 
-        "SELECT"
-        "   newExp.*"
-        " FROM newExp"
-        " LEFT JOIN newImfile"
-        "   USING(exp_tag)"
-        " LEFT JOIN rawExp"
-        "   USING(exp_tag)"
-        " WHERE"
-        "   newExp.exp_tag IS NOT NULL"
-        "   AND newImfile.exp_tag IS NULL"
-        "   AND rawExp.exp_tag IS NULL"
-        "   AND newExp.imfiles ="
-        "   (SELECT COUNT(exp_tag) FROM rawImfile"
-        "       WHERE rawImfile.exp_tag = newExp.exp_tag)"
-        "   AND newExp.exp_tag = '%s'";
+    psString query = pxDataGet("regtool_find_unprocessed_exp.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statment");
+        return false;
+    }
 
     if (!p_psDBRunQuery(config->dbh, query, exp_tag)) {
@@ -794,12 +754,9 @@
     }
 
-    // find all rawImfiles matching the default query
-    psString query = psStringCopy( 
-        "SELECT\n"
-        "   *\n"
-        " FROM rawExp\n"
-        " WHERE\n"
-        "   rawExp.exp_tag IS NOT NULL\n" // bogus where clause
-    );
+    psString query = pxDataGet("regtool_processedexp.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statment");
+        return false;
+    }
 
     if (config->where) {
