in reply to s/$foo// selective interpolation?

$chord[$RIGHT_DELIMITER] is being accessed as an array, try ${chord}[$RIGHT_DELIMITER]
                - Ant

Replies are listed 'Best First'.
(tye)Re: s/$foo// selective interpolation?
by tye (Sage) on May 15, 2001 at 19:52 UTC

    Good catch! Better still: s/[$LEFT_DELIMITER]\Q$chord\E[$RIGHT_DELIMITER]//g

    Update: After testing, I'd actually rewrite this as:

    $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;
    (note the lack of \ in the delimiter strings).

            - tye (but my friends call me "Tye")
      With the stipulation that you don't want $chord to possibly contain regexp info, very true.
                      - Ant