c:\@Work\Perl\monks>perl -wMstrict -le "my $string = '/.*u\/ba$/'; ;; my $flag = qr{ [msix] }xms; ;; my $convertable = my ($pattern, $modifiers) = $string =~ m{ \A \s* / (.*?) / ($flag*) \z }xms; die qq{bad rx: '$string'} unless $convertable; ;; my $rx = qr{(?$modifiers)$pattern}; print $rx; print 'A: match' if 'u/ba' =~ $rx; ;; my $ry = qr{ \A foo $rx }xms; print $ry ;; print 'B: match' if 'foolubatu/ba' =~ $ry; print 'C: match' if 'Foolubatu/ba' =~ $ry; " (?-xism:(?).*u\/ba$) A: match (?msx-i: \A foo (?-xism:(?).*u\/ba$) ) B: match