Did you check which file is missing, e.g. compare ls -la with your programs output? Is it always the same?
I checked your program here (SuSE 10.2, perl 5.8.8) and was surprised to see that there was a delta of one file too! Problem was counting the output of ls -la | wc -l vs. perl yourprogram.pl | wc -l. The delta was caused by this line: total 84! Maybe...?
Update: This works here:
#!/usr/bin/perl use strict; my %ls = map { chomp; $_ => 2 } qx{/bin/ls -1}; opendir(DIR,".") or die "cannot readdir here - $!"; $ls{$_}++ foreach readdir(DIR); my @where = ("","readir only", "ls only", "both"); foreach (sort keys %ls) { printf("%12s: %s\n", $where[ $ls{$_} ], $_); } __END__ readir only: . readir only: .. both: file1.pl both: file2.pl both: path
In reply to Re: readdir missing one file
by Perlbotics
in thread readdir missing one file
by true
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |