1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
# Perl Script
my($line,$list,$l,@lists,$v1,$v2,$debug,$output);
my($conf) = $ARGV[0];
$debug=0;
if( not $conf ){
print STDERR "use: $0 ifhp.conf file\n";
exit 1;
}
open( CONF, "<$conf") or die "cannot open '$conf'";
while( <CONF> ){
chomp();
if( /^# PRINTER / ){
s/^# PRINTER //;
if( /^-/ ){
s/-//;
$line .= $_;
} else {
if( $line ){
$output .= "### $line\n";
}
$line = $_;
}
} elsif( $line and /^\[/ ){
if( $line !~ /\%/ ){
print STDERR $line if $debug;
$output .= "### $line\n";
$line = "";
next;
}
@lists = split(' ',$_);
foreach $list (@lists){
next if not $list;
next if $list =~ /\[/;
next if $list =~ /\]/;
$l = $line;
print STDERR "X $list $l\n" if $debug;
$l =~ s/%/$list/;
print STDERR "$l\n" if $debug;
if( $l =~ m,{/(.*)/(.*)/}, ){
print STDERR "$1, $2\n" if $debug;
$v1 = $1;
$v2 = $2;
eval "\$list =~ s/$v1/$v2/";
print STDERR "Match '$list'\n" if $debug;
$l =~ s/{.*}/$list/;
print STDERR "Final $l\n" if $debug;
}
print STDERR "$l\n" if $debug;
$output .= "### $l\n";
}
$line = "";
}
}
close CONF;
print STDERR "OUTPUT ". $output if $debug;
$skip = 0;
print STDERR "XX START\n" if $debug;
while( <> ){
print STDERR "INPUT $_" if $debug;
if( /SUPPORTED START/ ){
print;
print $output;
print STDERR "YY $_" if $debug;
print STDERR "ZZ $output" if $debug;
$skip = 1;
} elsif( $skip ){
$skip = 0 if( /SUPPORTED END/ );
}
print if( not $skip );
if( $debug ){ print STDERR "XX $_" if( not $skip ); }
}
|