while () { unless (/hello/) { style2(); exit; } style1(); } sub style1 { print "hello\n"; } sub style2 { print "bye\n"; }