in reply to Re^2: readdir missing one file
in thread readdir missing one file

You still have two bugs and two instances of poor programming.
my $Tdir_qfn = "/var/www/campbell/campbell.edu/www/content/2/"; opendir(my $Tdir_dh, $Tdir_qfn) or die("Can't read dir \"$Tdir_qfn\": $!\n"); while (defined( my $f = readdir($Tdir_dh) )) { print "<li>$f\n"; } closedir($Tdir_dh);

Replies are listed 'Best First'.
Re^4: readdir missing one file
by JavaFan (Canon) on Oct 17, 2008 at 17:26 UTC
    You'll stop iterating prematurely if you have a file named 0 (zero).
    That hasn't been true for a very long time:
    perl -MO=Deparse -e 'while ($f = readdir $h) {1;}' while (defined($f = readdir $h)) { '???'; } -e syntax OK

      I personally believe that I've just discovered the second little bit of C<while> (being more) magic (than I already knew) in just a few days...

      --
      If you can't understand the incipit, then please check the IPB Campaign.