use strict; use warnings; my $w = q{}; my $x = q{}; my $y = q{}; my $z = q{}; cmpOr(); $x = q{abc}; cmpOr(); $z = q{abcdefghij}; cmpOr(); $z = q{abcdefgh}; cmpOr(); $y = q{abcdefgh}; cmpOr(); $z = q{abcdefghij}; cmpOr(); sub cmpOr { print qq{Comparing OR methods with:-\n}, qq{ \$w is ->$w<-\n}, qq{ \$x is ->$x<-\n}, qq{ \$y is ->$y<-\n}, qq{ \$z is ->$z<-\n}; if ($w =~ /abcdefgh/ || $x =~ /abcdefgh/ || $y =~ /abcdefgh/ || $z =~ /abcdefgh/) { print qq{ orig: true\n}; } else { print qq{ orig: false\n}; } if (q{abcdefgh} =~ /^(?:$w|$x|$y|$z)$/) { print qq{johngg: true\n}; } else { print qq{johngg: false\n}; } print qq{\n}; } #### Comparing OR methods with:- $w is -><- $x is -><- $y is -><- $z is -><- orig: false johngg: false Comparing OR methods with:- $w is -><- $x is ->abc<- $y is -><- $z is -><- orig: false johngg: false Comparing OR methods with:- $w is -><- $x is ->abc<- $y is -><- $z is ->abcdefghij<- orig: true johngg: false Comparing OR methods with:- $w is -><- $x is ->abc<- $y is -><- $z is ->abcdefgh<- orig: true johngg: true Comparing OR methods with:- $w is -><- $x is ->abc<- $y is ->abcdefgh<- $z is ->abcdefgh<- orig: true johngg: true Comparing OR methods with:- $w is -><- $x is ->abc<- $y is ->abcdefgh<- $z is ->abcdefghij<- orig: true johngg: true #### if (q{abcde} =~ /^(?=$var_a$)(?=$var_b$)(?=$var_c$)/)