2016-01-18 12:10:26 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
2016-01-21 14:00:19 +01:00
|
|
|
our $cond = 1;
|
|
|
|
our $condDone = 0;
|
2016-01-18 12:10:26 +01:00
|
|
|
our %args;
|
|
|
|
for ( my $i = 0 ; $i < @ARGV ; $i += 2 ) {
|
|
|
|
$args{ $ARGV[$i] } =
|
|
|
|
( $ARGV[ $i + 1 ] and $ARGV[ $i + 1 ] ne 'no' ) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (<STDIN>) {
|
2016-01-18 13:13:16 +01:00
|
|
|
if (m#//if:(\w+)#) {
|
2016-01-21 14:00:19 +01:00
|
|
|
$cond = $args{$1};
|
|
|
|
$condDone = $cond;
|
2016-01-18 13:13:16 +01:00
|
|
|
}
|
2016-01-21 14:00:19 +01:00
|
|
|
elsif (m#//elsif:(\w+)#) {
|
|
|
|
if ($condDone) {
|
|
|
|
$cond = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$cond = $args{$1};
|
|
|
|
$condDone ||= $cond;
|
|
|
|
}
|
2016-01-18 12:10:26 +01:00
|
|
|
}
|
|
|
|
elsif (m#//else#) {
|
2016-01-21 14:00:19 +01:00
|
|
|
$cond = !$condDone;
|
2016-01-18 12:10:26 +01:00
|
|
|
}
|
2016-01-18 13:13:16 +01:00
|
|
|
elsif (m#//endif#) {
|
|
|
|
$cond = 1;
|
2016-01-18 12:10:26 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
print if ($cond);
|
|
|
|
}
|
|
|
|
}
|