open my $DATA, "wlsendpts blah blah blah |" or die; while (<$DATA>) { next unless /End/ && !/tcp3/ && /reg/; # do whatever with this line of output }