Flexibler Textersatz

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

translate.pl
my $cmdname = $0; $cmdname =~ s{.*/}{};
my $usage = "Usage: $cmdname dictionary [file...]";
die $usage unless @ARGV >= 1;
my $dictionary = shift @ARGV;

my %dict = ();
my $dict = new IO::File $dictionary
   or die "$cmdname: unable to open $dictionary: $!\n";
while(<$dict>) {
   next if /^#/;
   chomp;
   my ($orig, $replace) = split /:/;
   $dict{$orig} = $replace;
}
$dict->close;

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 - 2003 Andreas Borchert, in HTML konvertiert am 01.10.2003