while (1) { my $time = time(); print $sock "$data\r\n"; my @output; my $output = join( '', @output ); while (<$sock>) { if ( $output = /$match/ ) { print STDOUT; open(STDOUT, "| $email"); last; } else { print STDOUT; open(STDOUT, "| $logger"); last; } } }