in reply to Perl List files in directory

Could this be a permissions issue?

Try changing your error message on the opendir to "Cannot open dir: $!" to see the details of what went wrong.

Try prefixing your code with the line: warn "Can't read /opt/tmp\n" unless -r "/opt/tmp";

Also, in general, you should use warnings; use strict; at the top of your scripts if you aren't already.