in reply to Perl script does not work on other directories?

If you use the glob function, instead of readdir, you'll get the file names with the path that you used to search them. The readdir function returns only the file names, without the path.

Replies are listed 'Best First'.
Re^2: Perl script does not work on other directories?
by Anonymous Monk on Nov 23, 2014 at 10:57 UTC

    I added the following right after opndir line:

     chdir DH, "$dir" or die "Couldn't change to that directory $dir: $!";

    and it works correctly now.Thanks for help.