if ( index($lineinfile, $currGB) == -1 ) { print "Debugging: continuing the loop\n"; next; } # Do your matching workload here. #### next unless ( index($lineinfile, $currGB) != -1 );