open($cmd, "tail -n 10 $ERRLOG |"); while(<$cmd>) { # do something here }