my $log = '/var/log/httpd-access.log'; open my $fh, "/usr/bin/egrep 'corp.home.ge.com|scotland.gcf.home.ge.com' $log |") or die "egrep failed on $log: $!"; while ( <$fh> ) { ... } close ($fh);