use strict; use diagnostics; $_ = "Before"; print "Before loop= $_\n"; while (<>){ print "In while loop= $_\n"; last; } print "After while loop= $_\n"; Output: Before loop= Before myinput (entered from the keyboard) In while loop= myinput After while loop= myinput