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
In reply to Re: ref and qx
by ikegami
in thread ref and qx
by didess
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |