JadeNB has asked for the wisdom of the Perl Monks concerning the following question:
“Why, yes,” you reply, “one can say in a regex”:
“But,” I reply, “what if you want to interpolate a pattern?”$ perl -E '/(?{ say "See?" })/' See?
Thoughts?$ perl -E 'use re "eval"; my $a = qr//; /(?{ say("See?") })$a/' Undefined subroutine &main::say called at (re_eval 1) line 1.
UPDATE: ambrus suggested in the CB to remind the compiler that I want to use 5.010, and that works:
which solves my problem, but seems strange. Why should the presence or absence of an empty regex require me to add an apparently superfluous use?$ perl -E 'use re "eval"; my $a = qr//; /(?{ use 5.010; say "See?" })$ +a/' See?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't say in a regex?
by ikegami (Patriarch) on Nov 21, 2009 at 18:07 UTC | |
by JavaFan (Canon) on Nov 21, 2009 at 18:19 UTC |