in reply to Re^2: In place replacement from reference list
in thread In place replacement from reference list

=~ m/^$path1|$path2|...etc/

I know LanX and kcott understand this, but here's a general side note. In a regex expression like the one quoted above, the ^ anchor is associated only with the first alternation, i.e., ^$path1. None of the other alternations are anchored.

The "precedence" of Perl ordered alternation is very low. This applies generally, so in
    $str =~ m/ a b c | d | e | f g h /x;
the regex pattern "atoms" a b c comprise the first possible alternation, then d if the first alternation cannot match, then e, then the f g h sequence.

Use grouping, typically non-capturing, to disambiguate precedence. E.g., in
    $str =~ m/ a b (?: c | d e | ... | etc) f g /x;
the sequence a b is required for a match, then the first of c or d e or ... or etc, then the required f g sequence.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^4: In place replacement from reference list
by LanX (Saint) on Sep 07, 2022 at 21:00 UTC
    I didn't think about that, it wasn't meant to be productive code just an illustration.

    Thanks for pointing that out! :)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery