3 # langwrap - language wrapper for building resources
5 # $Id: langwrap,v 1.2 2008-08-18 13:10:41 vg Exp $
19 $idStr = ' $Revision: 1.2 $ ';
20 $idStr =~ /Revision:\s+(\S+)\s+\$/
21 ?
($langwrapRev = $1) : ($langwrapRev = "-");
23 print "langwrap -- Version: $langwrapRev\n";
29 &parse_commandfile
($opt_c);
31 # create list with command lines
34 # finally execute commands
35 foreach $cmd (@command) {
42 print "langwrap: command execution failed with exitcode $res.\n";
50 ###### routines ######
52 ### parse_commandfile()
53 sub parse_commandfile
{
57 open(COMMAND
, "<$file") or die "canĀ“t open $file";
62 if ( ($line =~ //) || ($line =~ /^\r/) || ($line =~ /^#/) ) {
66 @field = split " ", $line;
69 $nfield = $#field + 1;
71 if ( $nfield != ($#field + 1) ) {
72 print "langwrap: error in <cmdfile>: every row must ";
73 print "have the same # of columns.\n";
83 sub create_commands
() {
84 my($cmd, $cmdline, $arg_string, $ntempl);
87 $arg_string = join(" ", @ARGV);
88 # just count the number of templates
89 $ntempl = ($arg_string =~ s/@\d+@/$&/eg);
90 if ( $ntempl >= $nfield ) {
91 print "lnagwrap: # of templates > # of fields in <cmdfile>.\n";
95 # create command lines
97 $cmdline = $arg_string;
98 $cmdline =~ s/@(\d+)@/$LoL[$i][$1]/eg;
99 push @command, $cmd . " " . $cmdline;
106 if ( !getopts
('c:') ) {
115 print "langwrap: $opt_c is not a readable file.\n";
120 print "langwrap: empty <template_string>.\n";
127 print "Usage: langwrap -c cmdfile tool <template_string>\n";
128 print "<template_string> is of form: ...\@1\@ .... \@2\@...\n";
129 print "with \@<n>\@ template #n\n";