File: make_rd.pl

package info (click to toggle)
r-cran-ff 4.5.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,924 kB
  • sloc: ansic: 7,297; cpp: 2,329; perl: 24; sh: 19; makefile: 5
file content (34 lines) | stat: -rw-r--r-- 927 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl
# reads the standard input line by line and writes out all lines
# that begin with "#!". The output is splitted into several output
# files as follows: Every time a line of the format "#! \name{<name>}
# is encountered, a file with the name "<name>.Rd" is created and
# the output is written into it (until the next line with this format
# is found). Thus, the first line beginning with "#!" must of this
# type, because otherwise the script would not know where to write
# the output to.

my $open = 0; 
while(<STDIN>)
{
    $line = $_;
    if( $line =~ /^#! ?(.*)/ )
    {
    	$line = $1;
        if( $line =~ /\\name\{(.*)\}/ )
        {
            $f = $1;
            if( $open )
            {
                close( OUT );
            }
            open( OUT, ">$f.rd" );
            $open = "true";
        }
        if( $open )
        {
        	print OUT $line . "\n";
        }
    }
}
close(OUT);