tomcrypt/filter.pl

31 lines
560 B
Perl
Raw Normal View History

2006-01-26 13:11:56 -05:00
#!/usr/bin/perl
# we want to filter every between START_INS and END_INS out and then insert crap from another file (this is fun)
use strict;
use warnings;
2006-01-26 13:11:56 -05:00
open(my $src, '<', shift);
open(my $ins, '<', shift);
open(my $tmp, '>', 'tmp.delme');
2006-01-26 13:11:56 -05:00
my $l = 0;
while (<$src>) {
2006-01-26 13:11:56 -05:00
if ($_ =~ /START_INS/) {
print {$tmp} $_;
2006-01-26 13:11:56 -05:00
$l = 1;
while (<$ins>) {
print {$tmp} $_;
2006-01-26 13:11:56 -05:00
}
close $ins;
2006-01-26 13:11:56 -05:00
} elsif ($_ =~ /END_INS/) {
print {$tmp} $_;
2006-01-26 13:11:56 -05:00
$l = 0;
} elsif ($l == 0) {
print {$tmp} $_;
2006-01-26 13:11:56 -05:00
}
}
close $tmp;
close $src;