Re: transforming german characters
From: John W. Krahn (someone_at_example.com)
Date: 08/09/04
- Next message: Matthew Braid: "Re: $class::SUPER as well as $instance::SUPER?"
- Previous message: Steve May: "Re: Hash reference question"
- In reply to: steve_f: "Re: transforming german characters"
- Next in thread: steve_f: "Re: transforming german characters"
- Reply: steve_f: "Re: transforming german characters"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 08 Aug 2004 23:41:42 GMT
steve_f wrote:
>
>>John W. Krahn wrote:
>>
>>Using a hash you could write that as:
>>
>>my %set1 = (
>> "\xDF" => 'ss',
>> );
>># Use a character class because all keys are single characters
>># If keys are multiple characters use alternation instead
>
> can you explain this a bit further? I'm not quite sure what you mean
> by alternation, but I really only looked up the escaped values for
> this particular problem.
Gunnar's example uses alternation.
>>my $key1 = '[' . join( '', keys %set1 ) . ']';
Changing this to use alternation would look something like:
my $key1 = '(?:' . join( '|', keys %set1 ) . ')';
> also here I start to get really lost....ok, you are loading into a scalar
> the keys as one long string...joining them with no space between...
> with two brackets so
>
> $key1 = [\xDF]
> $key2 = [\xC4\xD6\xDC\xE4\xF6\xFC]
> correct?
Yes.
> I see you use it down below in this substitution but it is a bit hard
> for me to understand:
>
> if ( $string =~ s/($key1)/$set1{$1}/og )
>
> well, if you have the time please give me a bit more clarrification
> on this because I haven't seen it before.
The substitution and match operators interpolate variables like double
quoted strings so after interpolation the substitution operator sees:
if ( $string =~ s/([\xDF])/ss/g )
John
-- use Perl; program fulfillment
- Next message: Matthew Braid: "Re: $class::SUPER as well as $instance::SUPER?"
- Previous message: Steve May: "Re: Hash reference question"
- In reply to: steve_f: "Re: transforming german characters"
- Next in thread: steve_f: "Re: transforming german characters"
- Reply: steve_f: "Re: transforming german characters"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|