http://qs321.pair.com?node_id=1205199


in reply to Tidying and simplifying a regular expression

Because I recently learned about regexp_pattern (see thread), this might work, but it might not handle every case (there are other flags besides "u"):
use re (); for (1..10) { my ($pat, $flags) = re::regexp_pattern($rex); $rex = ($flags eq "u" or $flags eq "") ? qr{$pat.} : qr{$rex.}; }