in reply to grep with looped tests
$final = 0 if ( $r );
You need to change $r to $something =~ $r; Using a regex variable as an expression by itself will not do any matching.
It might be more efficient to drop the loop and build a combined expression like
Maybe Regexp::Optimizer can make that long expression even faster.$something !~ /$r1|$r2|$r3|$r4|.../;
In Section
Seekers of Perl Wisdom