in reply to Re^2: How useful is the /o regexp modifier?
in thread How useful is the /o regexp modifier?

How about these:

m{.|<long pattern>} m{\!<long pattern>} # with ! not anywhere in the string you match

Both will match any long pattern very fast, the first one should be the fastest match possible as it matches just the first char of the string to match.

It could be that the long patterns are optimized away, that should be tested

UPDATE: On second thought, whether they are optimized away doesn't really matter as long as the compilation takes more time, and it does, at least with perl 5.8.8

#with short pattern m{.|U*e?Z+} horrid rx matches string Rate // qr/o qr /o // 1254/s -- -29% -30% -34% qr/o 1771/s 41% -- -1% -7% qr 1781/s 42% 1% -- -7% /o 1912/s 52% 8% 7% -- #with long pattern m{.|U*e?Z+J{0,1}z*4{0,1}7?d*H+k*l+N+d{0,1}4+9{0,1} +... 1000 more subpattern horrid rx matches string Rate // qr qr/o /o // 235/s -- -87% -87% -88% qr 1770/s 654% -- -1% -7% qr/o 1781/s 659% 1% -- -7% /o 1912/s 715% 8% 7% --