I presume that your brackets cannot be nested? Because in your example strong, all the dollars are between brackets. (Note also that as is, we cannot deduce there are dollar signs in $line, as $10 and $s are two interpolated variables. But let's assume there's a lone q before the first double quote).
Assume that the above is true, and that all brackets are balanced, I'd write something like:
{
no warnings 'uninitialized';
$line =~ s/(<[^>]*>|\$[0-9])|\$/$1/g;
}
Alternatively, keep the warning, replace the replacement with $1 || "" and use /e to eval the replacement. | [reply] [d/l] [select] |
| [reply] |
| [reply] [d/l] [select] |
if I have understood you correctly, this will do
$line =~ s/\$\d+|\$|<.*?>//g;
will make $line to
Lord: Of The Rings
BTW perlretut is your friend.
Please form your question correctly, I am not clear with your question. :(
Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.
| [reply] [d/l] |
The OP only wants to delete dollars that aren't inside brackets, and aren't followed by digits. You delete everything between brackets (including the brackets), and any following digits.
| [reply] |