while (defined($_ = ) || ($_ = "AFTERFILE")){ stuff; last if $_ eq "AFTERFILE"; } #### LOOP: { $_ = <>; stuff; redo LOOP if defined; }