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;
In reply to s/$foo// selective interpolation? by dotc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |