-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert-figures
executable file
·37 lines (35 loc) · 1.09 KB
/
insert-figures
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
36
#!/usr/bin/perl
while(<>) {
if(/INSERT_TEXT_FROM_FILE (.*) END/) {
my $codewrapper=0;
$file = $1;
print STDERR "File: $file\n";
if( $file =~ /(.*)\@DATE/ ) {
$base = $1;
print STDERR "Searching for base=$base\n";
# look for the newest file with @DATE, assumed to be in CWD.
opendir(DIR, "yang");
@files=readdir(DIR);
closedir(DIR);
#print STDERR join(',', @files);
my @sorted = reverse sort grep(/^$base@/,@files);
#print STDERR join(',', @sorted);
$file = "yang/" . shift @sorted;
print STDERR "Setting file=$file\n";
}
open(FILE, "<" . $file) || die "Can not open $file: $!\n";
print "<artwork><![CDATA[\n";
if($file =~ /\.yang$/) {
$codewrapper=1;
print "<CODE BEGINS> file \"$file\"\n"
}
while(<FILE>) {
print;
}
close(FILE);
print "<CODE ENDS>\n" if $codewrapper;
print "]]></artwork>\n";
} else {
print;
}
}