in reply to Re: Feature Idea: qr//e
in thread Feature Idea: qr//e (updated with solutions)
you don't want to operate on an array but a code-block
Would you accept something like the following as sufficiently equivalent?
sub qre(&;@) { my $block = shift; my $str = $block->(@_); return qr/$str/; }
(not tested)
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
some functional code:
use Data::Dump; sub qre(&;@) { my $block = shift; my $str = $block->(@_); return qr/$str/; } sub ored { return join '|', map {quotemeta} @_ } sub oredraw { return join '|', @_ } my @strings = qw/. | %/ ; dd qre {join '|', map {quotemeta} @strings }; dd qre \&ored, @strings; dd qre \&oredraw, @strings;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Feature Idea: qr//e
by haukex (Archbishop) on Jan 18, 2017 at 18:08 UTC | |
by TheDamian (Vicar) on Jan 19, 2017 at 22:42 UTC | |
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 AnomalousMonk (Archbishop) on Jan 19, 2017 at 22:57 UTC |