in reply to Regular Expression I think.

How about something like this? It requires that you know what kind of changes you'll make:
#!/usr/bin/perl -w use strict; # set up our changes my @lines = qw( This=That Some=Song ); my %changes = ( This => 'Other', Some => 'Corny' ); foreach my $line (@lines) { # for all the money $line =~ s/([^=]+)=/$changes{$1} . "="/e; } print join("\n", @lines), "\n";

Update: dchetlin is right, there's no need for /e. Oops.

Replies are listed 'Best First'.
RE: Re: Regular Expression I think.
by dchetlin (Friar) on Sep 27, 2000 at 01:05 UTC
    This is a good answer, and there are no problems with it.

    Just wanted to point out that it's one of those situations where the /e modifier seems like it's needed, but it's not.

    s/([^=]+)=/$changes{$1} . "="/e is effectively the same as s/([^=]+)=/$changes{$1}=/, but the latter is more efficient..

    On the other hand, using [^=]+ is a much cleaner and more efficient (and less error prone) solution than .*? which appears once or twice elsewhere in this thread.

    -dlc