[EMAIL PROTECTED] wrote:

> One more thing. My original goal was to replace several strings on a line.
> Do I need to do the "expansion" thing for each string that I want to
> replace? For example if I have a file that contains Unicode text and it has
> a line "Testing 1 2 3" in it and I want to replace the 1 with One, 2 with
> Two, and 3 with Three. The following does not work. It works with ANSI files
> but not Unicdoe.

Every search string will have to be expanded.
And, for that matter, you'll have to replace the expansion strings:

# this is four times as fast as s/// solution
sub toutf
{
        my $s = shift;
        pack('v*', unpack('c*', $s));
}

my %subs = ( toutf('1') => toutf('One'),
toutf('2') => toutf('Two'),
toutf('3') => toutf('Three') );

while (<>)
{
        my $line = $_;
        map { $line =~ s/$_/$subs{$_}/g } keys(%subs);
        print $line;
}

-- 
Ned Konz
currently: Stanwood, WA
email:     [EMAIL PROTECTED]
homepage:  http://www.bike-nomad.com

---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to