sub process_log { my ($log, $pattern) = @_; my @index = grep {$log->[$_] =~ m/^$FAILURE_SEARCH /} 0 .. $#$log; print "INFO: $log->[$_]This occurred on line $_\n" foreach @index; return join '', map {$log->[$_]} @index; } my $problems = process_log(\@Log, $FAILURE_SEARCH); #### sub process_log { my ($log_fh, $pattern) = @_; my @issues; while( my $line = <$log_fh> ){ if( $line =~ m/^$pattern / ) { chomp $line; print "INFO: $line\nThis occurred on line $.\n"; push @issues, { log_entry => $line, line_num => $. }; } } return @issues; }