Martin Costello wrote: > > John W. Krahn wrote: > > > >Here is one way to do it: > > > >$ perl -e' > >$text = q/ > > > >blahblah -blah blah > > -blah blah -blah $blah -blah "Ground" > > -c "blah transformC" transformC; > > > >blahblah > > -af transformC "blah" ($blah) > > -af AtransformC "blah" ($blah) > > -af transformC_2 "blah" ($blah) > > > >/; > > > >$text =~ s/("[^"]+"|\w+)/ > > $1 eq q(transformC) ? q(TRANSC) : > > $1 eq q("transformC") ? q("TRANSC") : $1 > > /eg; > >print "$text\n"; > >' > > > >blahblah -blah blah > > -blah blah -blah $blah -blah "Ground" > > -c "blah transformC" TRANSC; > > > >blahblah > > -af TRANSC "blah" ($blah) > > -af AtransformC "blah" ($blah) > > -af transformC_2 "blah" ($blah) > > Thank you ever so much - that seemed to work. > > In my code I'm actually using variables for the names to replace: > > so my substitute looks like this : > > $line =~ s/("[^"]+"|\w+)/ > $1 eq $oldList[$i] ? $newList[$i] : > $1 eq "$oldList[$i]" ? "$newList[$i]" : $1 > /eg; > > (I removed the q( ) parts from your script as it did n't work when I > used variables - what does the q( ) part mean?)
q() is another way of saying ''. All the quote operators can be found in the perlop.pod document under "Quote and Quote-like Operators" section. If you want your version to work correctly you are going to have to enclose the second test and replacement strings in double quotes: $line =~ s/("[^"]+"|\w+)/ $1 eq $oldList[$i] ? $newList[$i] : $1 eq qq("$oldList[$i]") ? qq("$newList[$i]") : $1 /eg; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]