#!/usr/bin/perl # # dbroweval # Copyright (C) 1991-1998 by John Heidemann # $Id: dbroweval,v 1.26 2003/05/23 04:17:49 johnh Exp $ # # This program is distributed under terms of the GNU general # public license, version 2. See the file COPYING # in $dblibdir for details. # sub usage { print <getopt) { $ch = $dbopts->opt; if ($ch eq 'b') { push (@beg_code, $dbopts->optarg); } elsif ($ch eq 'd') { $debug++; } elsif ($ch eq 'e') { push (@end_code, $dbopts->optarg); } elsif ($ch eq 'f') { push(@code_files, $dbopts->optarg); } elsif ($ch eq 'n') { $no_output = 1; } elsif ($ch eq 'N') { $no_output = 2; die "$0: -N not yet implemented\n"; } else { &usage; }; }; # # handle files # foreach (@code_files) { open(INF, "<$_") || die "$prog: cannot open ``$_''.\n"; push(@ARGV, join('', )); close INF; }; &readprocess_header; ($perl_code_f, $db_code_a_f, $title_f, $command_f) = (0..20); $pretty_args = ""; foreach $iref ([\$beg_code, \@beg_code, "BEGIN CODE:", "-b"], [\$code, \@ARGV, "CODE:", ""], [\$end_code, \@end_code, "END_CODE:", "-e"]) { next if ($#{$iref->[$db_code_a_f]} == -1); $c = ${$iref->[$perl_code_f]} = &codify(@{$iref->[$db_code_a_f]}); $pretty_args .= " $iref->[$command_f] { " . &code_prettify(@{$iref->[$db_code_a_f]}) . " }"; print STDERR "$iref->[$title_f]:\n$c\n" if ($debug); } exit 1 if ($debug); &write_header() if (!$no_output); eval $beg_code; $@ && die "$prog: error in eval of begin block: $@\n"; my($loop) = q[ row: while () { &pass_comments && next; &split_cols; {] . $code . q[;} &write_cols if (!$no_output); }; ]; eval $loop; $@ && die "$prog: error in eval of code: $@\n"; eval $end_code; $@ && die "$prog: error in eval of end block: $@\n"; $code =~ s/\n/ /g; # otherwise comments break print "# | $prog $pretty_args\n"; exit 0;