Random tips. You should use strict.pm which means you want a my in declaring $line. Also an 8-space indent is too much - in studies comprehension is best with an indent of 2-4 spaces. (There seems to be a marginal benefit to 4 spaces.)
Sure, these points may look picky. But a good style comes from consistency on trivial details.