in reply to $_ getting clobbered by inner loop.

while (<>) places each line to $_, and $_ is a global, so there. to avoid it (or actually, as a general rule), don't use $_ gratuitously. use an explicit variable.
  • Comment on Re: $_ getting clobbered by inner loop.