lemonldap-ng/scripts/transform-templates
2016-01-18 12:13:16 +00:00

29 lines
493 B
Perl
Executable File

#!/usr/bin/perl
use strict;
our $cond = 1;
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>) {
if (m#//if:(\w+)#) {
$cond = $args{$1};
}
elsif (m#//elsif:(\w+)# and not $cond) {
$cond = $args{$1};
}
elsif (m#//else#) {
$cond = !$cond;
}
elsif (m#//endif#) {
$cond = 1;
}
else {
print if ($cond);
}
}