File: menu.pl

package info (click to toggle)
css-validator 0~20250226%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 19,360 kB
  • sloc: java: 144,868; lisp: 1,153; makefile: 724; javascript: 485; xml: 423; cs: 290; sh: 121; perl: 35
file content (41 lines) | stat: -rwxr-xr-x 1,078 bytes parent folder | download
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
37
38
39
40
41
#!/usr/bin/perl

my $newmenu = "";
use Cwd;
my $cwdir = getcwd;
my $menuline;
my @langs;
open (menu_template, "menu.tmpl") or die("could not open menu template file");
while ($menuline = <menu_template>) {
     $newmenu .= $menuline; 
     if ($menuline =~ /xml:lang="(.*)"/){
         push @langs, $1;
     }
} 

my @files = ("manual.html", "about.html", "documentation.html", "DOWNLOAD.html");

my $html = "";
foreach my $filename (@files) {
    foreach my $ext (@langs) {
        $html = '';
        if (open (HTML, "../$filename.$ext")) {
            print "reading ../$filename.$ext\n";
            while ($htmlline = <HTML>) {
                $html .= $htmlline;
            }
            close(HTML);
            my $html_orig = $html;
            $html =~ s/(<ul id="lang_choice">.*?<\/ul>)/$newmenu/sgmi;
            $html =~ s/\$filename/$filename/gi;
            open (HTML, ">../$filename.$ext");
            
            print HTML $html;
            close HTML;
        }
        else {
            warn "could not open ../$filename.$ext";
        }
    }
}