in reply to use of 'or' in regex

(Use the <code> tag to delimit code blocks like your regex, or PM will interpret them as square-bracket special link codes...)

In this case, perl will return the list of those patterns that match. So you're ok, since your patterns don't overlap.

If you had something like this:

$str=~/(DPL|DPLA)/g
then the DPLA alternative would never match, since DPL would.

Edit: Someone said in /msg that I'm wrong if the string is "DPLA DPL", claiming both will match.

However, in that case, _DPL_ is what matches twice; DPLA never matches.

$ perl -ne'while(/(DPL|DPLA)/g){print " > $1 <\n"}' DPL > DPL < DPLA > DPL < DPLA DPL > DPL < > DPL < DPLA DPLA > DPL < > DPL <
If I had specified DPLA|DPL, then the match would have been as expected.
--
Mike