in reply to ref and qx
First, you're using qx (aka readpipe) instead of qr.
Second, \$refX is a reference to scalar $refX, and thus ref(\$refX) returns "SCALAR". If the value of $refX had been constructed using qr, ref($refX) would get you "Regex" since it contains a reference to a Regex.
I recommend that you use re::is_regexp instead if you're using Perl 5.10+. This will catch both references to regex patterns and a regex patterns themselves.
>perl -E"$r=qr/a/; say ref($r) eq 'Regexp' ||0" 1 >perl -E"$r=qr/a/; say ref($$r) eq 'Regexp' ||0" 0 >perl -E"$r=qr/a/; say re::is_regexp($r) ||0" 1 >perl -E"$r=qr/a/; say re::is_regexp($$r) ||0" 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: ref and qx
by Anonymous Monk on May 06, 2011 at 12:13 UTC |