in reply to Re: s/$foo// selective interpolation?
in thread s/$foo// selective interpolation?
Good catch! Better still: s/[$LEFT_DELIMITER]\Q$chord\E[$RIGHT_DELIMITER]//g
Update: After testing, I'd actually rewrite this as:
(note the lack of \ in the delimiter strings). - tye (but my friends call me "Tye")$LEFT_DELIMITER = '{['; $RIGHT_DELIMITER = '}]'; $tempstr = 'This is a string containing [Am]brackets.'; $chord = 'Am'; $tempstr =~ s/[\Q$LEFT_DELIMITER\E]\Q$chord\E[\Q$RIGHT_DELIMITER\E]//; print $tempstr;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re: s/$foo// selective interpolation?
by suaveant (Parson) on May 15, 2001 at 20:41 UTC |