<?xml version="1.0" encoding="windows-1252"?>
<node id="1004997" title="Re: grep {CONSTANT} @list" created="2012-11-21 14:52:40" updated="2012-11-21 14:52:40">
<type id="11">
note</type>
<author id="971084">
frozenwithjoy</author>
<data>
<field name="doctext">
&lt;p&gt;The way I see it, you still need to put &lt;c&gt;//&lt;/c&gt; around the pattern you are trying to match that is contained in &lt;c&gt;REGEX&lt;/c&gt; (in this case it is &lt;c&gt;(?^:string)&lt;/c&gt;).&lt;/p&gt;

&lt;c&gt;
say grep { REGEX } @list;
#doesn't work, because it isn't really doing what you think it is doing

say grep { /REGEX/ } @list;
#doesn't work because of the problems mentioned above when using constants in contexts that auto-quote barewords

say grep { /(?^:string)/ } @list;
#this works (and throws errors if // are removed)

use Readonly;
Readonly::Scalar my $regex_ro =&gt; qr/string/;
say grep {/$regex_ro/} @list;
#this works (and, as expected, gives same bad result you got if // is removed)

my $regex = qr/string/;
say grep { /$regex/ } @list;
#this works (and, as expected, gives same bad result you got if // is removed)
&lt;/c&gt;
</field>
<field name="root_node">
1004985</field>
<field name="parent_node">
1004985</field>
</data>
</node>
