in reply to Re^2: A perverse use of grepin thread A perverse use of grep
sub whatever { local $_; while(<$in>) { # do stuff } } [download]
Even if the loop is not in a sub, localizing $_ can prevent nasty bugs if you decided to wrap the loop in a sub later.