--- /home/.cpan/build/Mail-SpamAssassin-3.2.4-GVUlHj/blib/lib/Mail/SpamAssassin/Plugin/Check.pm	2008-01-05 15:10:50.000000000 -0600
+++ Check.pm	2008-04-07 10:34:34.000000000 -0500
@@ -18,6 +18,7 @@
 use Mail::SpamAssassin::Logger;
 use Mail::SpamAssassin::Util;
 use Mail::SpamAssassin::Constants qw(:sa);
+use IO::File ();
 
 use strict;
 use warnings;
@@ -47,6 +48,8 @@
 
   my $pms = $args->{permsgstatus};
 
+
+  $self->setup_eval_cache_dirs($pms);
   # bug 4353:
   # Do this before the RBL tests are kicked off.  The metadata parsing
   # will figure out the (un)trusted relays and such, which are used in the
@@ -242,8 +245,9 @@
   }
 
   # build up the eval string...
-  $self->{evalstr} = $self->start_rules_plugin_code($ruletype, $priority);
-  $self->{evalstr2} = '';
+  $self->init_evalstr(1);
+  $self->init_evalstr(2);
+  $self->add_evalstr($self->start_rules_plugin_code($ruletype, $priority));
 
   # use %nopts for named parameter-passing; it's more friendly to future-proof
   # subclassing, since new parameters can be added without breaking third-party
@@ -269,29 +273,36 @@
   undef &{$methodname};
   $self->free_ruleset_source($pms, $ruletype, $priority);
 
+  my $code_file = $self->{evalpath} . '/' . $ruletype . '_' . $priority . '.pm'; #should use file::spec ?
+  my $eval_fh = new IO::File $code_file, 'w';
+  
   my $evalstr = $self->{evalstr};
 
   # generate the loop that goes through each line...
-  $evalstr = <<"EOT";
+  print {$eval_fh} "
   {
     package $package_name;
 
-    $self->{evalstr2}
-
+    ";
+  $self->write_eval_code_to_fh(2,$eval_fh);
+  print {$eval_fh} "
     sub $methodname {
       my \$self = shift;
-      $evalstr;
+      ";
+  $self->write_eval_code_to_fh(1,$eval_fh);
+  print {$eval_fh} '
     }
-
     1;
   }
-EOT
+  ';
 
-  delete $self->{evalstr};
-  delete $self->{evalstr2}; # free up some RAM before we eval()
+  $self->stop_evalstr(1); #close file
+  $self->stop_evalstr(2); #close file
+  $eval_fh->close();
 
   ## dbg ("rules: eval code to compile: $evalstr");
-  eval $evalstr;
+  dbg("brining in: " . $code_file );
+  eval { do $code_file; };
   if ($@) {
     warn("rules: failed to compile $ruletype tests, skipping:\n\t($@)\n");
     $pms->{rule_errors}++;
@@ -302,16 +313,64 @@
   }
 }
 
+sub setup_eval_cache_dirs {
+	my ($self,$pms) = @_;
+	$self->{'evalpath'} = $pms->{main}->sed_path('__local_state_dir__/evalcache/__version__');
+	dbg('check: eval path is ' . $self->{'evalpath'});
+	if (! -e $self->{'evalpath'}) {
+		my $evalbase = $pms->{main}->sed_path('__local_state_dir__/evalcache');
+		dbg("check: eval base is $evalbase");
+		if (! -e $evalbase) {
+			mkdir($evalbase,0755);
+		}
+
+		mkdir($self->{evalpath},0755);
+	}
+}
+
+sub init_evalstr {
+	my($self,$strnum) = @_;
+	$self->stop_evalstr($strnum);
+	$self->{eval_files}->{$strnum} = IO::File->new_tmpfile();
+}
+
+sub stop_evalstr {
+	my($self,$strnum) = @_;
+	if (exists $self->{eval_files}->{$strnum} && ref $self->{eval_files}->{$strnum} =~ /IO::File/) { $self->{eval_files}->{$strnum}->close(); }
+}
+
+sub write_eval_code_to_fh {
+	my ($self,$strnum,$fh) = @_;
+
+	if ( $_[0]->{eval_files}->{$strnum}) {
+		seek($_[0]->{eval_files}->{$strnum}, 0 , 0); #beginning of fh
+		while(readline($_[0]->{eval_files}->{$strnum})) {
+			print {$fh} $_;
+		}
+	}
+}
+
 sub add_evalstr {
-  my ($self, $str) = @_;
-  $self->{evalstr} .= $str;
+	#avoid allocating new memory for variables
+	#$_[0] is self
+	#$_[1] is the code
+	if (!defined $_[0]->{eval_files}->{1}) {
+		warn("rules: failed to open temporary perl file");
+	}
+	#write the eval code to the temp file
+	print {$_[0]->{eval_files}->{1}} $_[1];
 }
 
 sub add_evalstr2 {
-  my ($self, $str) = @_;
-  $self->{evalstr2} .= $str;
+	#avoid allocating new memory for variables
+	#$_[0] is self
+	#$_[1] is the code
+	if (!defined $_[0]->{eval_files}->{2}) {
+		warn("rules: failed to open temporary perl file");
+	}
+	#write the eval code to the temp file
+	print {$_[0]->{eval_files}->{2}} $_[1];
 }
-
 sub add_temporary_method {
   my ($self, $methodname, $methodbody) = @_;
   $self->add_evalstr2 (' sub '.$methodname.' { '.$methodbody.' } ');
@@ -355,7 +414,7 @@
         # the " || 0" formulation is to avoid "use of uninitialized value"
         # warnings; this is better than adding a 0 to a hash for every
         # rule referred to in a meta...
-        $meta{$rulename} .= "(\$h->{'$token'} || 0) ";
+        $meta{$rulename} .= "(\$h->{'$token'}||0) ";
       
         if (!exists $conf->{scores}->{$token}) {
           dbg("rules: meta test $rulename has undefined dependency '$token'");
@@ -380,10 +439,7 @@
     pre_loop_body => sub
   {
     my ($self, $pms, $conf, %opts) = @_;
-    $self->add_evalstr ('
-      my $r;
-      my $h = $self->{tests_already_hit};
-    ');
+    $self->add_evalstr ('my $r;my $h=$self->{tests_already_hit};');
   },
     post_loop_body => sub
   {
@@ -418,16 +474,11 @@
               } split (' ', $conf->{meta_dependencies}->{ $metas[$i] } );
 
         if ($alldeps ne '') {
-          $self->add_evalstr ('
-            $self->ensure_rules_are_complete(q{'.$metas[$i].'}, qw{'.$alldeps.'});
-          ');
+          $self->add_evalstr ('$self->ensure_rules_are_complete(q{'.$metas[$i].'},qw{'.$alldeps.'});');
         }
 
         # Add this meta rule to the eval line
-        $self->add_evalstr ('
-          $r = '.$meta{$metas[$i]}.';
-          if ($r) { $self->got_hit(q#'.$metas[$i].'#, "", ruletype => "meta", value => $r); }
-        ');
+        $self->add_evalstr ('$r='.$meta{$metas[$i]}.';if($r){$self->gh(q#'.$metas[$i].'#,"",ruletype=>"meta",value=>$r);}');
 
         splice @metas, $i--, 1;    # remove this rule from our list
       }
@@ -491,14 +542,7 @@
     # override this; useful for profiling rule runtimes, although I think
     # the HitFreqsRuleTiming.pm plugin is probably better nowadays anyway
       if ($self->{main}->{use_rule_subs}) {
-      $self->add_temporary_method ($rulename.'_head_test', '{
-          my($self,$text) = @_;
-          '.$self->hash_line_for_rule($pms, $rulename).'
-	    while ($text '.$testtype.'~ '.$pat.'g) {
-            $self->got_hit(q#'.$rulename.'#, "", ruletype => "header");
-            '. $self->hit_rule_plugin_code($pms, $rulename, "header", "last") . '
-            }
-        }');
+      $self->add_temporary_method ($rulename.'_head_test', '{while ($_[1] '.$testtype.'~ '.$pat.'g) {$self->gh(q#'.$rulename.'#, "", ruletype => "header");'. $self->hit_rule_plugin_code($pms, $rulename, "header", "last") . '}}');
     }
     else {
       # store for use below
@@ -508,9 +552,7 @@
     pre_loop_body => sub
   {
     my ($self, $pms, $conf, %opts) = @_;
-    $self->add_evalstr ('
-      my $hval;
-    ');
+    $self->add_evalstr ('my $hval;');
   },
     post_loop_body => sub
   {
@@ -518,17 +560,10 @@
     # setup the function to run the rules
     while(my($k,$v) = each %ordered) {
       my($hdrname, $def) = split(/\t/, $k, 2);
-      $self->add_evalstr ('
-        $hval = $self->get(q#'.$hdrname.'#, q#'.$def.'#);
-      ');
+      $self->add_evalstr ('$hval=$self->get(q#'.$hdrname.'#,q#'.$def.'#);');
       foreach my $rulename (@{$v}) {
         if ($self->{main}->{use_rule_subs}) {
-          $self->add_evalstr ('
-            if ($scoresptr->{q#'.$rulename.'#}) {
-              '.$rulename.'_head_test($self, $hval);
-              '.$self->ran_rule_plugin_code($rulename, "header").'
-            }
-          ');
+          $self->add_evalstr ('if($scoresptr->{q#'.$rulename.'#}){'.$rulename.'_head_test($self, $hval);'.$self->ran_rule_plugin_code($rulename,"header").'}');
         }
         else {
           my $testcode = $testcode{$rulename};
@@ -545,17 +580,7 @@
             $matchg = 'g';
           }
 
-          $self->add_evalstr ('
-          if ($scoresptr->{q#'.$rulename.'#}) {
-            '.$posline.'
-            '.$self->hash_line_for_rule($pms, $rulename).'
-            '.$ifwhile.' ($hval '.$testcode.$matchg.') {
-              $self->got_hit(q#'.$rulename.'#, "", ruletype => "header");
-              '.$self->hit_rule_plugin_code($pms, $rulename, "header", $hitdone).'
-            }
-            '.$self->ran_rule_plugin_code($rulename, "header").'
-          }
-          ');
+	$self->add_evalstr ('if($scoresptr->{q#'.$rulename.'#}){'.$posline.' '.$ifwhile.' ($hval '.$testcode.$matchg.'){$self->gh(q#'.$rulename.'#,"",ruletype=>"header");'.$self->hit_rule_plugin_code($pms, $rulename, "header", $hitdone).'}'.$self->ran_rule_plugin_code($rulename, "header").'}');
         }
       }
     }
@@ -582,55 +607,26 @@
     {
       # support multiple matches
       $loopid++;
-      $sub = '
-      body_'.$loopid.': foreach my $l (@_) {
-        pos $l = 0;
-        '.$self->hash_line_for_rule($pms, $rulename).'
-        while ($l =~ '.$pat.'g) { 
-          $self->got_hit(q{'.$rulename.'}, "BODY: ", ruletype => "body"); 
-          '. $self->hit_rule_plugin_code($pms, $rulename, 'body',
-					 "last body_".$loopid) . '
-        }
-      }
-      ';
+      $sub = ' body_'.$loopid.': foreach my $l (@_){pos $l=0;while($l=~ '.$pat.'g){$self->gh(q{'.$rulename.'},"BODY: ",ruletype=>"body");'. $self->hit_rule_plugin_code($pms, $rulename, 'body',"last body_".$loopid) . '}}';      
     }
     else {
       # omitting the "pos" call, "body_loopid" label, use of while()
       # instead of if() etc., shaves off 8 perl OPs.
-      $sub = '
-      foreach my $l (@_) {
-        '.$self->hash_line_for_rule($pms, $rulename).'
-        if ($l =~ '.$pat.') { 
-          $self->got_hit(q{'.$rulename.'}, "BODY: ", ruletype => "body"); 
-          '. $self->hit_rule_plugin_code($pms, $rulename, "body", "last") .'
-        }
-      }
-      ';
+      $sub = 'foreach my $l (@_){if($l=~ '.$pat.'){$self->gh(q{'.$rulename.'},"BODY: ",ruletype=>"body");'. $self->hit_rule_plugin_code($pms, $rulename, "body", "last") .'}}';
     }
 
     if ($self->{main}->{use_rule_subs}) {
-      $self->add_evalstr ('
-        if ($scoresptr->{q{'.$rulename.'}}) {
-          '.$rulename.'_body_test($self,@_); 
-          '.$self->ran_rule_plugin_code($rulename, "body").'
-        }
-      ');
+      $self->add_evalstr ('if($scoresptr->{q{'.$rulename.'}}){'.$rulename.'_body_test($self,@_);'.$self->ran_rule_plugin_code($rulename,"body").'}');
     }
     else {
-      $self->add_evalstr ('
-        if ($scoresptr->{q{'.$rulename.'}}) {
-          '.$sub.'
-          '.$self->ran_rule_plugin_code($rulename, "body").'
-        }
-      ');
+      $self->add_evalstr ('if ($scoresptr->{q{'.$rulename.'}}){'.$sub.' '.$self->ran_rule_plugin_code($rulename,"body").'}');
     }
 
     next if ($opts{doing_user_rules} &&
             !$self->is_user_rule_sub($rulename.'_body_test'));
 
     if ($self->{main}->{use_rule_subs}) {
-      $self->add_temporary_method ($rulename.'_body_test',
-        '{ my $self = shift; '.$sub.' }');
+      $self->add_temporary_method ($rulename.'_body_test','{ my $self = shift; '.$sub.' }');
     }
   }
   );
@@ -652,44 +648,16 @@
     my $sub;
     if (($conf->{tflags}->{$rulename}||'') =~ /\bmultiple\b/) {
       $loopid++;
-      $sub = '
-      uri_'.$loopid.': foreach my $l (@_) {
-        pos $l = 0;
-        '.$self->hash_line_for_rule($pms, $rulename).'
-        while ($l =~ '.$pat.'g) { 
-           $self->got_hit(q{'.$rulename.'}, "URI: ", ruletype => "uri");
-           '. $self->hit_rule_plugin_code($pms, $rulename, "uri",
-					  "last uri_".$loopid) . '
-        }
-      }
-      ';
+      $sub = ' uri_'.$loopid.': foreach my $l (@_){pos $l=0;while($l=~ '.$pat.'g){$self->gh(q{'.$rulename.'},"URI: ",ruletype=>"uri");'. $self->hit_rule_plugin_code($pms, $rulename, "uri", "last uri_".$loopid) . '}}';
     } else {
-      $sub = '
-      foreach my $l (@_) {
-        '.$self->hash_line_for_rule($pms, $rulename).'
-        if ($l =~ '.$pat.') { 
-           $self->got_hit(q{'.$rulename.'}, "URI: ", ruletype => "uri");
-           '. $self->hit_rule_plugin_code($pms, $rulename, "uri", "last") .'
-        }
-      }
-      ';
+      $sub = ' foreach my $l (@_){if($l=~'.$pat.'){$self->gh(q{'.$rulename.'},"URI: ",ruletype=>"uri");'. $self->hit_rule_plugin_code($pms, $rulename, "uri", "last") .'}}';
     }
 
     if ($self->{main}->{use_rule_subs}) {
-      $self->add_evalstr ('
-        if ($scoresptr->{q{'.$rulename.'}}) {
-          '.$rulename.'_uri_test($self, @_);
-          '.$self->ran_rule_plugin_code($rulename, "uri").'
-        }
-      ');
+      $self->add_evalstr ('if($scoresptr->{q{'.$rulename.'}}){'.$rulename.'_uri_test($self, @_);'.$self->ran_rule_plugin_code($rulename, "uri").'}');
     }
     else {
-      $self->add_evalstr ('
-        if ($scoresptr->{q{'.$rulename.'}}) {
-          '.$sub.'
-          '.$self->ran_rule_plugin_code($rulename, "uri").'
-        }
-      ');
+      $self->add_evalstr ('if($scoresptr->{q{'.$rulename.'}}){'.$sub.$self->ran_rule_plugin_code($rulename,"uri").'}');
     }
 
     next if ($opts{doing_user_rules} &&
@@ -721,45 +689,17 @@
     {
       # support multiple matches
       $loopid++;
-      $sub = '
-      rawbody_'.$loopid.': foreach my $l (@_) {
-        pos $l = 0;
-        '.$self->hash_line_for_rule($pms, $rulename).'
-        while ($l =~ '.$pat.'g) { 
-           $self->got_hit(q{'.$rulename.'}, "RAW: ", ruletype => "rawbody");
-           '. $self->hit_rule_plugin_code($pms, $rulename, "rawbody",
-					  "last rawbody_".$loopid) . '
-        }
-      }
-      ';
+      $sub = ' rawbody_'.$loopid.': foreach my $l (@_){pos $l=0;while($l=~ '.$pat.'g) {$self->gh(q{'.$rulename.'},"RAW: ",ruletype=>"rawbody");'. $self->hit_rule_plugin_code($pms, $rulename, "rawbody","last rawbody_".$loopid) . '}}';
     }
     else {
-      $sub = '
-      foreach my $l (@_) {
-        '.$self->hash_line_for_rule($pms, $rulename).'
-        if ($l =~ '.$pat.') { 
-           $self->got_hit(q{'.$rulename.'}, "RAW: ", ruletype => "rawbody");
-           '. $self->hit_rule_plugin_code($pms, $rulename, "rawbody", "last") . '
-        }
-      }
-      ';
+      $sub = 'foreach my $l (@_){if($l=~ '.$pat.'){$self->gh(q{'.$rulename.'},"RAW: ",ruletype=>"rawbody");'.$self->hit_rule_plugin_code($pms,$rulename,"rawbody","last").'}}';
     }
 
     if ($self->{main}->{use_rule_subs}) {
-      $self->add_evalstr ('
-        if ($scoresptr->{q{'.$rulename.'}}) {
-           '.$rulename.'_rawbody_test($self, @_);
-           '.$self->ran_rule_plugin_code($rulename, "rawbody").'
-        }
-      ');
+      $self->add_evalstr ('if($scoresptr->{q{'.$rulename.'}}){'.$rulename.'_rawbody_test($self, @_);'.$self->ran_rule_plugin_code($rulename, "rawbody").'}');
     }
     else {
-      $self->add_evalstr ('
-        if ($scoresptr->{q{'.$rulename.'}}) {
-          '.$sub.'
-          '.$self->ran_rule_plugin_code($rulename, "rawbody").'
-        }
-      ');
+      $self->add_evalstr ('if($scoresptr->{q{'.$rulename.'}}){'.$sub.' '.$self->ran_rule_plugin_code($rulename, "rawbody").'}');
     }
 
     next if ($opts{doing_user_rules} &&
@@ -786,24 +726,12 @@
     pre_loop_body => sub
   {
     my ($self, $pms, $conf, %opts) = @_;
-    $self->add_evalstr ('
-      my $fullmsgref = shift;
-    ');
+    $self->add_evalstr ('my $fullmsgref=shift;');
   },
                 loop_body => sub
   {
     my ($self, $pms, $conf, $rulename, $pat, %opts) = @_;
-    $self->add_evalstr ('
-      if ($scoresptr->{q{'.$rulename.'}}) {
-        pos $$fullmsgref = 0;
-        '.$self->hash_line_for_rule($pms, $rulename).'
-        while ($$fullmsgref =~ '.$pat.'g) {
-          $self->got_hit(q{'.$rulename.'}, "FULL: ", ruletype => "full");
-          '. $self->hit_rule_plugin_code($pms, $rulename, "full", "last") . '
-        }
-        '.$self->ran_rule_plugin_code($rulename, "full").'
-      }
-    ');
+    $self->add_evalstr ('if($scoresptr->{q{'.$rulename.'}}){pos $$fullmsgref=0;while($$fullmsgref=~ '.$pat.'g){$self->gh(q{'.$rulename.'},"FULL: ",ruletype=>"full");'.$self->hit_rule_plugin_code($pms, $rulename, "full", "last").'}'.$self->ran_rule_plugin_code($rulename,"full").'}');
   }
   );
 }
@@ -881,16 +809,31 @@
   my $have_start_rules = $self->{main}->have_plugin("start_rules");
   my $have_ran_rule = $self->{main}->have_plugin("ran_rule");
 
-  # the buffer for the evaluated code 
-  my $evalstr = q{ };
-  $evalstr .= q{ my $function; };
+  # the fh for the evaluated code 
+  my $code_file = $self->{evalpath} . '/' . 'eval' . '_' . $priority . '.pm'; #should use file::spec ?
+  my $eval_fh = new IO::File $code_file, 'w';
+  print {$eval_fh}
+"
+{
+  package $package_name;
+
+    sub ${methodname} {
+      my (\$self, \@extraevalargs) = \@_;
+
+      my \$scoresptr = \$self->{conf}->{scores};
+      my \$prepend2desc = q#$prepend2desc#;
+      my \$rulename;
+      my \$result;
+
+      ";
+
+
+  print {$eval_fh} q{ my $function; };
  
   # conditionally include the dbg in the eval str
   my $dbgstr = q{ };
   if (would_log('dbg')) {
-    $dbgstr = q{
-      dbg("rules: ran eval rule $rulename ======> got hit ($result)");
-    };
+    $dbgstr = q{;dbg("rules: ran eval rule $rulename ======> got hit ($result)"); };
   }
 
   while (my ($rulename, $test) = each %{$evalhash})  { 
@@ -915,97 +858,49 @@
       next;
     }
  
-    $evalstr .= '
-    if ($scoresptr->{q#'.$rulename.'#}) {
-      $rulename = q#'.$rulename.'#;
-      $self->{test_log_msgs} = ();
-    ';
+     print {$eval_fh} 'if($scoresptr->{q#'.$rulename.'#}){$rulename=q#'.$rulename.'#;$self->{test_log_msgs}=();';
  
     # only need to set current_rule_name for plugin evals
     if ($eval_pluginsref->{$function}) {
       # let plugins get the name of the rule that is currently being run,
       # and ensure their eval functions exist
-      $evalstr .= '
-
-        $self->{current_rule_name} = $rulename;
-        $self->register_plugin_eval_glue(q#'.$function.'#);
-
-      ';
+       print {$eval_fh} '$self->{current_rule_name}=$rulename;$self->register_plugin_eval_glue(q#'.$function.'#);';
     }
 
     # this stuff is quite slow, and totally superfluous if
     # no plugin is loaded for those hooks
     if ($have_start_rules) {
       # XXX - should we use helper function here?
-      $evalstr .= '
-
-        $self->{main}->call_plugins("start_rules", {
-                permsgstatus => $self,
-                ruletype => "eval",
-                priority => '.$priority.'
-              });
-
-      ';
+       print {$eval_fh} '$self->{main}->call_plugins("start_rules",{permsgstatus=>$self,ruletype=>"eval",priority=>'.$priority.'});';
     }
  
-    $evalstr .= '
-
-      eval {
-        $result = $self->' . $function . ' (@extraevalargs '. $argstr .' );
-      };
-      if ($@) { $self->handle_eval_rule_errors($rulename); }
-
-    ';
+     print {$eval_fh} 'eval{$result=$self->' . $function . ' (@extraevalargs '. $argstr .' );};if($@){$self->handle_eval_rule_errors($rulename);}';
 
     if ($have_ran_rule) {
       # XXX - should we use helper function here?
-      $evalstr .= '
-
-        $self->{main}->call_plugins("ran_rule", {
-            permsgstatus => $self, ruletype => "eval", rulename => $rulename
-          });
-
-      ';
+       print {$eval_fh} '$self->{main}->call_plugins("ran_rule",{permsgstatus=>$self,ruletype=>"eval",rulename=>$rulename});';
     }
 
-    $evalstr .= '
-
-      if ($result) {
-        $self->got_hit($rulename, $prepend2desc, ruletype => "eval", value => $result);
-        '.$dbgstr.'
-      }
-    }
-    ';
+     print {$eval_fh} 'if($result){$self->got_hit($rulename,$prepend2desc,ruletype=>"eval",value=>$result);'.$dbgstr.'}}';
   }
 
   # don't free the eval ruleset here -- we need it in the compiled code!
 
   # nothing done in the loop, that means no rules 
-  return unless ($evalstr);
- 
-  $evalstr = <<"EOT";
-{
-  package $package_name;
-
-    sub ${methodname} {
-      my (\$self, \@extraevalargs) = \@_;
-
-      my \$scoresptr = \$self->{conf}->{scores};
-      my \$prepend2desc = q#$prepend2desc#;
-      my \$rulename;
-      my \$result;
-
-      $evalstr
+ print {$eval_fh} "
     }
 
   1;
 }
-EOT
+";
+
+  $eval_fh->close();
+  dbg("brining in: " . $code_file );
 
   undef &{$methodname};
-  eval $evalstr;
+  eval { do $code_file; };
 
-  if ($@) {
+    if ($@) {
     warn "rules: failed to compile eval tests, skipping some: $@\n";
     $self->{rule_errors}++;
   }
@@ -1038,21 +933,10 @@
 sub start_rules_plugin_code {
   my ($self, $ruletype, $pri) = @_;
 
-  my $evalstr = '
-
-      # start_rules_plugin_code '.$ruletype.' '.$pri.'
-      my $scoresptr = $self->{conf}->{scores};
-
-  ';
+  my $evalstr = 'my $scoresptr=$self->{conf}->{scores};';
 
   if ($self->{main}->have_plugin("start_rules")) {
-    $evalstr .= '
-
-      $self->{main}->call_plugins ("start_rules", { permsgstatus => $self,
-                                                    ruletype => \''.$ruletype.'\',
-                                                    priority => '.$pri.' });
-
-    ';
+    $evalstr .= '$self->{main}->call_plugins("start_rules",{permsgstatus=>$self,ruletype=>\''.$ruletype.'\',priority=>'.$pri.'});';
   }
 
   return $evalstr;
@@ -1069,17 +953,12 @@
 
   my $debug_code = '';
   if (exists($pms->{should_log_rule_hits})) {
-    $debug_code = '
-        dbg("rules: ran '.$ruletype.' rule '.$rulename.' ======> got hit: \"" . '.
-            $match.' . "\"");
-    ';
+    $debug_code = 'dbg("rules: ran '.$ruletype.' rule '.$rulename.' ======> got hit: \"" . '.$match.' . "\"");';
   }
 
   my $save_hits_code = '';
   if ($pms->{save_pattern_hits}) {
-    $save_hits_code = '
-        $self->{pattern_hits}->{q{'.$rulename.'}} = '.$match.';
-    ';
+    $save_hits_code = '$self->{pattern_hits}->{q{'.$rulename.'}}='.$match.';';
   }
 
   # if we're not running "tflags multiple", break out of the matching
