+# this writes out the filter in a form suitable to be read in by 'read_in'
+# It expects a list of references to filter lines
+sub write_out
+{
+ my $sort = shift;
+ my $call = shift;
+ my $fn = "$filterbasefn/$sort";
+
+
+ # make the output directory
+ mkdir $fn, 0777 unless -e $fn;
+
+ # write out the file
+ $fn = "$fn/$call.pl";
+ unless (open FILTER, ">$fn") {
+ warn "can't open $fn $!" ;
+ return;
+ }
+
+ my $today = localtime;
+ print FILTER "#!/usr/bin/perl
+#
+# Filter for $call stored $today
+#
+\$in = [
+";
+
+ my $ref;
+ for $ref (@_) {
+ my ($action, $field, $fieldsort, $comp, $actiondata) = @{$ref};
+ print FILTER "\t[ $action, $field, $fieldsort,";
+ if ($fieldsort eq 'n' || $fieldsort eq 'r') {
+ print FILTER "[ ", join (',', $comp), " ],";
+ } elsif ($fieldsort eq 'a') {
+ my $f = $comp;
+ print FILTER "'$f'";
+ }
+ print FILTER " ],\n";
+ }
+ print FILTER "];\n";
+ close FILTER;
+}