in reply to How to print the qr regex to the stdout?

Stringification of a compiled regex produces something that can be used in other qr//, m// or s/// without changing the meaning of the pattern. Adding (?^:...) or similar is necessary to achieve that.

my $re = qr/a/; say "a" =~ /$re/ || 0; # 1 say "A" =~ /$re/ || 0; # 0 say "a" =~ /$re/i || 0; # 1 say "A" =~ /$re/i || 0; # 0 my $pat1 = "(?^:a)"; say "a" =~ /$pat1/ || 0; # 1 say "A" =~ /$pat1/ || 0; # 0 say "a" =~ /$pat1/i || 0; # 1 say "A" =~ /$pat1/i || 0; # 0 my $pat2 = "a"; say "a" =~ /$pat2/ || 0; # 1 say "A" =~ /$pat2/ || 0; # 0 say "a" =~ /$pat2/i || 0; # 1 say "A" =~ /$pat2/i || 0; # 1 XXX

That said, you can get the unmodified pattern (and the flags) using re's re::regexp_pattern.

my ( $pat, $flags ) = re::regexp_pattern( $re );

You can rebuild the original compiled regex using the following:

my $re = eval "no re; qr/\$pat/$flags";