Flexibler Textersatz

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]

translate.pl
#!/usr/local/bin/perl -w

($cmdname = $0) =~ s{.*/}{};
die "Usage: $cmdname dictionary [file...]"
   unless @ARGV >= 1;
$dict = shift @ARGV;

%dict = ();
open(DICT, "<$dict") ||
   die "$cmdname: unable to open $dict\n";
while(<DICT>) {
   next if /^#/;
   chomp;
   ($orig, $replace) = split /:/;
   $dict{$orig} = $replace;
}
close(DICT);

while (<>) {
   s{\w+}{
      defined $dict{$&}?
         $dict{$&}
      :
         $&
   }xge;
   print;
}

*Dieses Skript ersetzt aufgrund einer Übersetzungstabelle alle Worte, die es in der Eingabe findet. Dabei werden unbekannte Worte unverändert gelassen.
 

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]
Copyright © 1996, 1998, 1999, 2000 Andreas Borchert, in HTML konvertiert am 07.02.2000