Hi LanX,
sub qre(&;@) { my $block = shift; my $str = $block->(@_); return qr/$str/; }
Thanks, that's an excellent piece of inspiration! Just to take that idea a little further and add support for /i and the like:
sub qre (&;$) { my $re = shift->(); eval 'qr/$re/'.(shift//'') || die $@ } my $regex = qre{ join '|', qw/foo bar/ }'i'; print "$regex\n"; __END__ (?^i:foo|bar)
Not that I'm going to start using this right away, for now this is just to satisfy my curiosity ;-)
Thanks,
-- Hauke D
In reply to Re^3: Feature Idea: qr//e
by haukex
in thread Feature Idea: qr//e (updated with solutions)
by haukex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |