Simple code:
use 5.014;
use warnings;
my $re = <DATA>;
chomp $re;
my $re2 = qr/$re/;
say $re2;
__END__
^\w$
result:
(?^u:^\w$) #added the (?^u:
Is any correct way to decompile $re2 getting back the original regex?
Motivation: the regex is an config value, so need:
- read it
- compile it
- save it to the file for the later use.
But can't save the compiled regex for the later use, because in every compiling the regex got expanded with the (?^u:, so after several cycles i ended with like:
(?^u:(?^u:(?^u:(?^u:(?^u:^\w$)))))
therefore the question are:
- is here any correct way, how to save the compiled version?
- if no way - how to decompile, to getting the original version?
- any idea?