Please do not change global variables in your module, at least without localizing them. It may cause very nasty hard to debug side effects. Replace while (<DATA>) { .. } with local $_; while (<DATA>) { .. }. See while(<>) { ... } considered harmful why.