Hello, thank you for your prompt response.
It appears that s///eeg gives me part of what I want. It seems to interpolate the $1 when it is alone. But it is an incomplete solution for me.
If instead of just getting rid of the brackets I want to replace them with words:
#!/usr/bin/perl
use warnings;
use strict;
sub replace {
s/$_[0]/$_[1]/eeg;
}
$_ = 'a { b } c ( d ) e';
my $nobrackets = qr/[^\{^\}]+/;
replace(qr/\{($nobrackets)\}/, ' leftbracket $1 rightbracket '); # I w
+ant to replace the brackets with the words leftbracket and rightbrack
+et.
print "$_\n";
This appears to make the { b } vanish entirely.