Minor style/correctness whinge, but I believe $hash{$file} = \@final_data;
should be $hash{$file}=[@final_data];. I suppose it wouldn't matter if you strictly used my @foo; every time the loop went around, but I think this way would be cleaner and less chance to bug up someplace..