In the case that matches where "re=(?^:(0-4))", the ref was blank. I felt this was confusing -- since if you first assign the "qr" expression to a scalar and check the ref, you do get a ref of Regexp. But if you put it directly into the hash and do a ref on the key you pull out, the ref-type is lost. After the qr-expression has been used as a key in a hash, you lose the reference. At that point, determining that it was a Regexp, is a bit "unpretty", in that it seems one would test if the expression began with '(?'.my %hash=(qr{([0-4])}=>"foo", a=>"foo2"); $_=2; for my $re (keys %hash) { P "re=%s, ref=%s", $re, ref $re; P "match:(%s) %s", $1, $hash{$re} if /$re/; } ' re=a, ref= re=(?^:([0-4])), ref= match:(2) foo
Also, the '^' being inserted after '(?' looks odd since the original 'qr' expression didn't include it. Do you know why it was inserted in the stringified version?
At this point, to check whether or not I need to use the 'key' directly or use it in a RE it seems I look for the paren, question-mark, which just looks strange, even though it works.
In reply to Re^4: how to use string RE (against $_ and capture)
by perl-diddler
in thread how to use string RE (against $_ and capture)
by perl-diddler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |