in reply to Perl List files in directory

Hi,

I tried using :

@files = glob("/opt/tmp/*");

i don't get any output. I checked the folder permissions and i have : drwxrwxwx

I also tried:

opendir(DIR, "/opt/tmp/") or die "Cannot open dir"; @files = grep {"/opt/tmp/*.xml"} readdir DIR;

I get an error : "Cannot open dir". However, like i mentioned before the folder as all permissions

I tried using Tiny, but i got an error saying: "can't locate Path/Tiny.pm in @INC

Im going to try and use find next

Replies are listed 'Best First'.
Re^2: Perl List files in directory
by Corion (Patriarch) on Apr 22, 2014 at 14:23 UTC

    As you have already been advised in Re: Perl List files in directory, please make your error messages more informative:

    opendir(DIR, "/opt/tmp/") or die "Cannot open dir: $!";

    This will tell you the immediate cause of the problem.

      I did that, i only get: "Cannot open dir: No such file or directory at ./script.pl line 28".

      which doesn't had much.

        It tells us that /opt/tmp does not exist.