ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
12.5 Reading a Directory HandleOnce we have a directory handle open, we can read the list of names with opendir(ETC,"/etc") || die "no etc?: $!"; while ($name = readdir(ETC)) { # scalar context, one per loop print "$name\n"; # prints ., .., passwd, group, and so on } closedir(ETC);
And here's a way of getting them all in alphabetical order with the assistance of opendir(ETC,"/etc") || die "no etc?: $!"; foreach $name (sort readdir(ETC)) { # list context, sorted print "$name\n"; # prints ., .., passwd, group, and so on } closedir(ETC); The names include files that begin with a dot. This is unlike globbing with |