http://qs321.pair.com?node_id=1143939


in reply to Is this a bug in perl regex engine or in my brain?

Works for me. You can also remove one pair of parentheses:
#!/usr/bin/perl use warnings; use strict; use Test::More; my $regex1 = qr/(2[0-4]|1?[0-9])?[0-9]/; my $regex2 = qr/(2[0-4]|1?[0-9])?[0-9]|25[0-5]/; for my $n (0 .. 1000) { if ($n < 250 || $n > 255) { is($n =~ /^$regex1$/, $n =~ /^$regex2$/, "match for $n"); } else { ok($n =~ /^$regex2$/, "match 2nd regex for $n"); isnt($n =~ /^$regex1$/, $n =~ /^$regex2$/, "match for $n"); } } done_testing();
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ