#!/usr/bin/perl use warnings; my $gotit = ""; until ("" ne $gotit) { $gotit = ; # Look for the pattern "abcd" in the incoming data chomp $gotit; if($gotit){last;} # to exit the loop after the pattern detection print("Pattern is not detected\n"); # print the message till pattern is detected. } print "action after the loop\n"; __DATA__ bingo #### Pattern is not detected Pattern is not detected Pattern is not detected action after the loop