Welcome to mirror list, hosted at ThFree Co, Russian Federation.

fix-info.perl « ems « scripts - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 98139f21147485fd8c9fcdc3bb17b6ca3cd909f5 (plain)
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
#!/usr/bin/env perl 

use strict;

my ($file,$step) = @ARGV;
$step = "*" unless defined($step);

die("fix-info.perl file [step]") unless defined($file);
die("file not found") unless -e $file;
die("full path!") unless $file =~ /^\//; 
my @filestat = stat($file);
my $newtime = $filestat[9];

open(LS,"ls steps/$step/*INFO|") || die;
while(my $info = <LS>) {
    chop($info);
    my @INFO = `cat $info`;
    my $changed = 0;
    foreach (@INFO) {
	if (/$file .*\[/) {
	    $changed++;
	    s/($file) (.*\[)\d+/$1 $2$newtime/g;
	}  
    }
    if ($changed) {
	print "updating $info\n";
	open(INFO,">$info");
	foreach (@INFO) { print INFO $_; }
	close(INFO);
    }
}
close(LS);