my $digits_4 = qr{ (?<!-)\b[0-9]{4}\b(?!-) }xms;
...
$unitslist_4 = "1001,1002,1003,1004,...,2504,2505";
...
unless ($digits_4 =~ /$unitslist/) { ... }
$digits_4 =~ /$unitslist/ seems to be matching the stringization of Regexp (regex or qr//) object $digits_4 to a string $unitslist of all possible unit numbers (assuming $unitslist is the same as $unitslist_4) that has been compiled as a match regex. I don't understand the purpose of this.
unless ($digits_4 =~ /$unitslist/) { ... } is doing the match described above and executing a conditional block (which contains the substitution) if there is no match. I don't understand this either.
A simple approach to the general problem would be to uniquely mark all unit number sub-strings: %1234% or {{1234}}. This would also allow for easy support of unit numbers like 123A or 12-B or C-4 or even Penthouse! Substitution matching then becomes straightforward and unambiguous.
Update: A spelling correction, and a few minor wording changes for clarity.
Give a man a fish: <%-{-{-{-<
In reply to Re: Text switching (updated)
by AnomalousMonk
in thread Text switching
by htmanning
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |