Re: perl / Umlaute ersetzen

Jan Trippler <[email protected]>
Newsgroups gmane.linux.suse.programming
Message-ID <[email protected]>
Hi,

Am Mittwoch, 18. April 2007 17:54 schrieb Hans Moser:
[...]
> Das folgende Bsp. (google-Fund) macht es nicht.
>
> my %UMLAUTE = ( 'Ä' => 'Ae', 'Ö' => 'Oe', 'Ü' => 'Ue', 'ä' =>
> 'ae', 'ö' => 'oe', 'ü' => 'ue' );
> my @UMLKEYS = join("|", keys(%UMLAUTE));
> $du_name =~ s/(@UMLKEYS)/$UMLAUTE{$1}/g;

Da ist nur ein kleiner Fehler drin:
my %UMLAUTE = ( 'Ä' => 'Ae', 'Ö' => 'Oe', 'Ü' => 'Ue', 'ä' =>
'ae', 'ö' => 'oe', 'ü' => 'ue' );
my $UMLKEYS = join("|", keys(%UMLAUTE));
$du_name =~ s/($UMLKEYS)/$UMLAUTE{$1}/g;

Aus "perldoc -f join":
       join EXPR,LIST
               Joins the separate strings of LIST into a single
               string with fields separated by the value of EXPR,
               and returns that new string.
...

Das Ergebnis eines join in ein Array zu schreiben (@UMLKEYS) ist 
also Quatsch - das Ergebnis ist ein String.

Gruß
Jan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.