cwilbur, yes, the perl script above was exactly what i was looking for. here’s what happened though:
$ perl -MRegexp::Common -pi.bak -e ‘s/P\(($RE{balanced}{-parens=>q{()}})\)/P[$1]/g;’ test.txt
Can’t locate Regexp/Common.pm in @INC (@INC contains: /opt/local/lib/perl5/5.8.8/darwin-2level /opt/local/lib/perl5/5.8.8 /opt/local/lib/perl5/site_perl/5.8.8/darwin-2level /opt/local/lib/perl5/site_perl/5.8.8 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl/5.8.8/darwin-2level /opt/local/lib/perl5/vendor_perl/5.8.8 /opt/local/lib/perl5/vendor_perl .).
BEGIN failed—compilation aborted.
so, i did a
sudo port install p5-regexp-common
this time, i got no error, but also no change. so, then i created a file called test.txt that contains whose entirety is: P()
running the perl script on that also did nothing. does it work for you? one issue might be that when i copy&paste the above line into terminal (i’m running osx), it replaces the single quotes with ?^?^?. i manually replaced them. can you think of anything? many thanks