File size: 717 Bytes
158b61b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env perl
#
# This file is part of moses.  Its use is licensed under the GNU Lesser General
# Public License version 2.1 or, at your option, any later version.

#retain lines in clean.lines-retained.1
use strict;
use warnings;

binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");

my $retainPath = $ARGV[0];

open(LINE_RETAINED, $retainPath);
my $retainLine = <LINE_RETAINED>;

my $lineNum = 0;
while (my $line = <STDIN>) {
    chomp($line);
    ++$lineNum;

    if ($retainLine == $lineNum) {
        print "$line\n";
	if ($retainLine = <LINE_RETAINED>) {
	    # do nothing
	}
        else {
            # retained lines is finished.
            $retainLine = 0;
        }
    }
}