The reason it isn't working is that you aren't opening the files. Readir returns a list of
. You have to open and read from each of the files.
I'm assuming you are the poster of an almost identical question earlier today. The answer to this question is in the replies to the last question.
Also, you are coding without strict or warnings. You cannot expect to learn to write good Perl code without them.