foreach (@files) { $file = "$klarfdir"."\\"."$_"; $file = Klarf::Parser->new($file); foreach (keys %{$file-> defectdata}){ #this never ends, but if I print $_ only, it works fine. print ($file -> defectdata -> {$_} -> {XINDEX}); } }