I want to test whether some string contains exactly 2 occurences of something. But this does not work:
my $outs = <<'EOS'; A B C A B D EOS # ok(2 == $outs =~ m|A|gs, "checking exactly 2 matches"); if( 2 == $outs =~ m|A|gs ){ print "exactly 2 matches\n" }
Is it possible to force list context in a conditional?
In reply to most terse regex match count by bliako
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |