Rev | Line | |
---|
[1] | 1 | #!/usr/bin/perl
|
---|
| 2 | #
|
---|
| 3 | #
|
---|
| 4 | # write a list of object filenames to an .rsp file,
|
---|
| 5 | # formatted according to tlib's input requirements
|
---|
| 6 | #
|
---|
| 7 | # usage: rsp_formatter infile.rsp
|
---|
| 8 | # where: infile.rsp is a one line file consisting of
|
---|
| 9 | # object filenames
|
---|
| 10 | # output: is the tlib-formatted infile.rsp
|
---|
| 11 | # note: multiple input files can be specified, e.g.
|
---|
| 12 | # rsp_formatter infile1.rsp infile2.rsp -etc.-
|
---|
| 13 |
|
---|
| 14 | use Fatal qw/ open /;
|
---|
| 15 | use File::Basename;
|
---|
| 16 | use Text::ParseWords;
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | foreach (@ARGV) {
|
---|
| 20 |
|
---|
| 21 | # loop (re)initialisation:
|
---|
| 22 | @words = ();
|
---|
| 23 | @new_words =();
|
---|
| 24 |
|
---|
| 25 | ($name,$path,$suffix) = fileparse($_,"\.rsp");
|
---|
| 26 | print "formatting $name$suffix for input to tlib...\n";
|
---|
| 27 |
|
---|
| 28 | # open, read explicitly so we can treat one ARGV at a time:
|
---|
| 29 | open INFILE, "$_";
|
---|
| 30 | $line=<INFILE>;
|
---|
| 31 | close INFILE;
|
---|
| 32 | chomp($line);
|
---|
| 33 |
|
---|
| 34 | @words = &parse_line('\s+', 0, $line);
|
---|
| 35 |
|
---|
| 36 | $i=0;
|
---|
| 37 | foreach(@words) {
|
---|
| 38 | if ($i < $#words) {
|
---|
| 39 | push( @new_words, "+$_ &");
|
---|
| 40 | }
|
---|
| 41 | else {
|
---|
| 42 | push( @new_words, "+$_,$name");
|
---|
| 43 | }
|
---|
| 44 | $i++;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | open(OUTFILE, ">$_");
|
---|
| 48 | foreach(@new_words) {
|
---|
| 49 | print OUTFILE "$_\n";
|
---|
| 50 | }
|
---|
| 51 | close(OUTFILE);
|
---|
| 52 |
|
---|
| 53 | print "...done\n";
|
---|
| 54 | }
|
---|
| 55 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.