while (<$fh>) { if (/Running|Dump|FromCB|Update/o) { push ( @lines, filterLog($_) ); } } #### push @lines, grep { /Running|Dump|FromCB|Update/o && filterLog($_) } <$fh>;