File: filter.pl

package info (click to toggle)
dropbear 0.51-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,496 kB
  • ctags: 4,893
  • sloc: ansic: 66,671; sh: 3,039; makefile: 621; perl: 409; asm: 30
file content (30 lines) | stat: -rw-r--r-- 517 bytes parent folder | download | duplicates (18)
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
#!/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)

$dst = shift;
$ins = shift;

open(SRC,"<$dst");
open(INS,"<$ins");
open(TMP,">tmp.delme");

$l = 0;
while (<SRC>) {
   if ($_ =~ /START_INS/) {
      print TMP $_;
      $l = 1;
      while (<INS>) {
         print TMP $_;
      }
      close INS;
   } elsif ($_ =~ /END_INS/) {
      print TMP $_;
      $l = 0;
   } elsif ($l == 0) {
      print TMP $_;
   }
}

close TMP;
close SRC;