You're missing a $ in my (regex) = @_. Also, you can qr// an empty string, which will break your regex.
Simplifying and enhancing a bit more results in something like:
sub deregex { my $regex = shift; my ($ops, $pat) = $regex =~ /^\(\? ([msix-]+) : (.*) \)$/x or die "Unknown qr// format"; $pat =~ s!/!\\/!g; $ops =~ s/-.*//; return "/$pat/$ops"; }
— Arien
In reply to Re: Deregex
by Arien
in thread Deregex
by Dylan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |