open(TAIL, "tail -f /var/log/messages |") or die "etc"; while () { if(/type1/) { print SUBLOG1 $_; } if(/type2/) { print SUBLOG2 $_; } # etc }