|Welcome to the Monastery|
Feature Idea: qr//e (updated with solutions)by haukex (Bishop)
|on Jan 18, 2017 at 13:47 UTC||Need Help??|
haukex has asked for the wisdom of the Perl Monks concerning the following question:
As I was thinking about this node about dynamically building regexes, I had the idle thought that it might be nice if qr// supported qr//e, analogous to s///e it would eval the inside of the construct before parsing it as a regex. Now this is really just a very minor itch, and I don't yet have any idea of how much sense it makes or how difficult it might be to implement, but I still thought I'd bounce it off of you.
Thoughts? Maybe the "normal" and/or "hacked" solutions below are good enough, and the effort required to implement qr//e isn't worth it? Other potential problems I haven't noticed yet?
Update 2017-01-19: TIMTOWTDI has already provided plenty of possible solutions, and I just wasn't feeling creative enough at the moment to see them :-) Thank you very much, LanX, Haarg, and vr! I updated the code with your solutions, and added Test::More and sub testre.
Update almost 6 months later: I just happened to stumble across this node: qr// with /e? :-)