Debian Codegraph @

wtools/aceExtract

raw
1 #!/usr/local/bin/perl
2 #
3 # perl script to extract objects from an ace file
4 #
5 # usage: aceExtract class:name acefile ...
6 #
7 # perl regexp allowed in name (but protect from shell globbing)
8 #
9 # $Id: aceExtract,v 1.1 1995/08/08 14:40:49 rd Exp $
10
11 $_ = shift(@ARGV) || die "usage: aceExtract class:name acefile ...\n" ;
12
13 s/^'(.*)'$/$1/ ;
14 (($class, $name) = /(\S+):(.*)/) || die "Can't parse class:name from arg 1 = $_\n" ;
15 #print "Class = $class, Name = $name\n" ;
16
17 while (<>) {
18 s/\/\/.*// ; # ace file comments
19 s/(\S+)\s+:/$1 / ; # horrid ':' separator
20 if ( /^(\S+)\s+(.*)\s*$/ ) {
21 $isPrint = ($1 eq $class && $2 =~ $name) ;
22 print if $isPrint ;
23 if ($class eq "LongText") {
24 while (<>) {
25 s/\/\/.*// ; # ace file comments
26 print if $isPrint ;
27 last if /^\*\*\*LongTextEnd\*\*\*\n$/ ;
28 }
29 }
30 else {
31 while (<>) {
32 s/\/\/.*// ; # ace file comments
33 print if $isPrint ;
34 last if /^\S*$/ ;
35 }
36 }
37 }
38 }