use strict; for (1 .. 1e8){ eval { if ((chr($_) =~ m/\W/) xor (chr($_) =~ m/[^\w]/)){ print "Counter-example with chr($_)\n"; } } }