I have 3 worthwhile solutions.

1. s2p on original sed file  (Paul Johnson)
2. perl -p .....            (Paul [[EMAIL PROTECTED]])
3. Randall's convert to hash..(Randall...)

I'll give all three the ol' corporate try :(
Method which I like best gets a 10%cut from my check from Ed McMahon...

Thanks Paul, Paul, and Randall for the feedback...

Frank

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 19, 2001 1:21 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: sed to perl


>>>>> "Frank" == Frank Newland <[EMAIL PROTECTED]> writes:

Frank> 3. The file list_of_changes  contains 6000+ lines and sed balks at
such a
Frank> large set of commands.
Frank> How can I do this in perl? 


if you can get the data into a hash, like

        my %map = ( 'fred' => 'frederick', 'barney' => 'barnard' );

then you can do a massive regex-replace, like:

my $regex = join "|", map quotemeta $_, reverse sort keys %map;
s/($regex)/map{$1}/g;

The "reverse sort" ensures that 'barney' is preferred over 'barn'.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to