in reply to Re^2: CMD says files is closed when It should be open
in thread CMD says files is closed when It should be open

readdir returns ., the current directory, as one of the entries in the current directory. You only want to work with files, so you can add
next unless -f $data;
after line 18.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ