Thanks to all, and Luke was right: I should have used $dir.$file instead of $file, it is correct now.
About the use File::stat or use File::Stat - Stat with a big S is unknown in my Perl?! Cannot install File::Stat in cpan! So I used File::stat (small 's'), and even as you suggested removed it and used the stat inside function. All is right now, thank you!