in reply to regex question: How do I modify in place in only one character class?
Putting aside the very odd goal...
The following regex will work for you.
By using a look behind assertion \K and a look ahead assertion, we can simply inject " selected" into the appropriate option:$selection =~ s/<option [^>]*\K(?=>\s*\Q$value\E\b)/ selected/;
In Section
Seekers of Perl Wisdom