dotc has asked for the wisdom of the Perl Monks concerning the following question:
Running this outputs, This is a string containing Am]brackets. instead of, This is a string containing brackets. I think I need s///; to interpolate $LEFT_DELIMITER and $RIGHT_DELIMITER, but not to attempt to interpolate $tempstr itself. Am I confused?$LEFT_DELIMITER = '{\['; $RIGHT_DELIMITER = '}\]'; $tempstr = 'This is a string containing [Am]brackets.'; $chord = 'Am'; $tempstr =~ s/[$LEFT_DELIMITER]$chord[$RIGHT_DELIMITER]//; print $tempstr;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: s/$foo// selective interpolation?
by suaveant (Parson) on May 15, 2001 at 17:29 UTC | |
by tye (Sage) on May 15, 2001 at 19:52 UTC | |
by suaveant (Parson) on May 15, 2001 at 20:41 UTC |