in reply to substitute using a hash
You may not need the quotemeta() in the map() but I've just added it 'just in case'.my %iso8859 = ( "\xA0" => ' ', "\xA1" => '¡', "\xA2" => '¢', "\xA3" => '£', "\xA4" => '¤', "\xA5" => '¥', "\xA6" => '¦', ); my $string = "a £ a penny"; my $regex = join '|', map quotemeta, keys %iso8859; $string =~ s/($regex)/$iso8859{$1}/g; print $string; __output__ a £ a penny
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: substitute using a hash
by vinfizz (Initiate) on May 07, 2002 at 17:38 UTC |