in reply to pattern detection inside until loop in perl

And that is just what your script is already doing. I changed your script slightly to make it a bit more obvious:

#!/usr/bin/perl use warnings; my $gotit = ""; until ("" ne $gotit) { $gotit = <DATA>; # 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 i +s detected. } print "action after the loop\n"; __DATA__ bingo

This prints:

Pattern is not detected Pattern is not detected Pattern is not detected action after the loop