in reply to Re^3: Feature Idea: qr//e
in thread Feature Idea: qr//e (updated with solutions)
One extra tweak to the prototype would allow you to
add trailing modifiers without requiring the pesky quotes
around them:
or, from Perl 5.20 onwards:sub qre (&;*) { my $re = shift->(); eval 'qr/$re/'.(shift//'') || die $@ } my $regex = qre{ join '|', qw/foo bar/ }i; print "$regex\n"; __END__
Damiansub qre :prototype(&;*) { my $re = shift->(); eval 'qr/$re/'.(shift//'') || die $@ } my $regex = qre{ join '|', qw/foo bar/ }i; print "$regex\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Feature Idea: qr//e
by choroba (Cardinal) on Jan 19, 2017 at 22:51 UTC | |
by TheDamian (Vicar) on Jan 20, 2017 at 19:54 UTC | |
by haukex (Archbishop) on Jan 21, 2017 at 10:10 UTC | |
by AnomalousMonk (Archbishop) on Jan 19, 2017 at 23:25 UTC | |
by LanX (Saint) on Jan 20, 2017 at 12:38 UTC | |
by huck (Prior) on Jan 20, 2017 at 13:11 UTC | |
by LanX (Saint) on Jan 20, 2017 at 13:20 UTC | |
by LanX (Saint) on Jan 20, 2017 at 14:42 UTC | |
Re^5: Feature Idea: qr//e
by AnomalousMonk (Archbishop) on Jan 19, 2017 at 22:57 UTC |
In Section
Seekers of Perl Wisdom