Index: branches/cache/ippScripts/scripts/phase0_imfile.pl
===================================================================
--- branches/cache/ippScripts/scripts/phase0_imfile.pl	(revision 9493)
+++ branches/cache/ippScripts/scripts/phase0_imfile.pl	(revision 9499)
@@ -80,5 +80,5 @@
 
 my $c = Cache::File->new(
-    cache_root => File::Spec->catdir($ENV{'HOME'}, '.', basename($0)),
+    cache_root => File::Spec->catdir($ENV{'HOME'}, '.pxtools', basename($0)),
     default_expires => '7200 sec',
 );
@@ -92,18 +92,6 @@
     my $command = "$ppStats $uri -recipe PPSTATS " . RECIPE; # Command to run ppStats
 
-    ### cache hook
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf );
-    my $cmd_output = $c->get($command) if $cache;
-    if (defined $cmd_output) {
-        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf )
-            = @{thaw $cmd_output};
-    } else {
-        my @output = run(command => $command, verbose => 1);
-        $c->set($command, freeze \@output) if $cache;
-        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf )
-            = @output;
-    }
-    ### end cache hook
-
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        cache_run(command => $command, verbose => 1);
     die "Unable to perform ppStats on exposure id $exp_tag: $error_code\n"
         if not $success;
@@ -146,4 +134,18 @@
 }
 
+sub cache_run
+{
+    my %p = @_;
+
+    my $cmd_output = $c->get($p{command}) if $cache;
+    if (defined $cmd_output) {
+        return @{thaw $cmd_output};
+    } else {
+        my @output = run(%p);
+        $c->set($p{command}, freeze \@output) if $cache;
+        return @output;
+    }
+}
+
 # Pau.
 
