#!/usr/bin/env perl # # pm_1155868_first_grep_large_file_2.pl [no modules] # use strict; use warnings; use autodie; open my $lines_fh, '<', input_filename(); while (<$lines_fh>) { next unless is_a_match($_); process_match($_) and last; } sub input_filename { 'pm_1155868_input.txt' } sub get_strings { [qw{rst uvw xyz}] } BEGIN { my $re = '(?:' . join('|', @{get_strings()}) . ')'; sub is_a_match { $_[0] =~ /$re/ } } sub process_match { print "Match: $_[0]" } #### $ pm_1155868_first_grep_large_file_2.pl Match: dddddddxyzdddd