in reply to Opening Directory and reading all file names and directory names

"what I did wrong"

The learned choroba answered that question; your program lacked recursion. I recommend using Path::Iterator::Rule for this kind of recursive file-finding exercise. I like its compact and clear syntax, as shown in this simple demo:

use strict; use warnings; use feature 'say'; use Path::Iterator::Rule; my $dir = '1230046/public_html/software'; my $_numMissing = 0; my $_filesThere = 0; my $r = Path::Iterator::Rule->new->file->exists->and(sub { my $wanted = $_[0] =~ s!software/!!r; -e $wanted ? $_filesThere++ : $_numMissing++ && say "$wanted is mi +ssing"; })->all($dir); say " Found: $_filesThere"; say "Missing: $_numMissing"; __END__

Test directory structure:

ls -R 1230046 1230046: public_html 1230046/public_html: 42.txt 43.txt bar quux software 1230046/public_html/bar: 42.txt baz 1230046/public_html/bar/baz: 42.txt 43.txt 1230046/public_html/quux: 43.txt 1230046/public_html/software: 42.txt 43.txt bar foo quux 1230046/public_html/software/bar: 42.txt 43.txt baz 1230046/public_html/software/bar/baz: 42.txt 43.txt 1230046/public_html/software/foo: 42.txt 43.txt baz 1230046/public_html/software/foo/baz: 42.txt 43.txt 1230046/public_html/software/quux: 42.txt 43.txt

Output:

$ perl 1230046.pl 1230046/public_html/foo/42.txt is missing 1230046/public_html/foo/43.txt is missing 1230046/public_html/quux/42.txt is missing 1230046/public_html/foo/baz/42.txt is missing 1230046/public_html/foo/baz/43.txt is missing Found: 6 Missing: 6

Hope this helps!


The way forward always starts with a minimal test.