my %match = ( 'pattern_one' => 1, 'pattern_two' => 1, ); while () { next unless ( m/(match_pattern)/ ); print "PAGE ->\t$name\ndata ->"; print $match{$1} ? "\t\t$1\nMatched ->\t$hit\n" : " TEXT INFO HERE\n"; push(@files, $name); $ct++; } close(F); #### my %match = ( 'pattern_one' => [\&sub_one, $results_one], 'pattern_two' => [\&sub_two, $results_two], ); while () { chomp; next unless ( m/(match_pattern)/ ); unless ( $match{$1} ) { #something basic goes here next; } # get the right function from our dispatch table ($func, $results) = [ $match{$1} ]; # now call it, pass it the text to process, and store the # results. $results = &$func($1); } # END while close(F);