1. use -w or 'use warnings;'. I consider programs buggy without it.
2. ALWAYS check the return code of system calls (e.g. open(), opendir() etc).
3. You could use 'use stritct;'. It is good to use.
4. You can use here documents to print multiple lines without needing to write multiple prints.