Hello , in your examples you're opening "files" not dir's , to open a directory use this instead opendir(DIR,$dirname) or die $!; my @content = readdir(DIR); closedir(DIR); then to read files inside it , for (@content){ print ; } that's it , if you need to remove ("." and "..") which means the top directorys most of time use it as follow : opendir(DIR,$dirname) or die $!; my @content = grep {! /^\./},readdir(DIR); closedir(DIR); then again read them using for (@content){ print; } That's it HTH
On 9/26/05, Tom Allison <[EMAIL PROTECTED]> wrote: > > Wiggins d'Anconia wrote: > > Please bottom post... > > > > Daniel Kurtz wrote: > > > >>Ooh ooh ooh! One I know! > >> > >>open(COMMAND, "dir |"); > >>@files = <COMMAND>; > >> > > > > Well, there's two methods that I use where I can and they are probably > more portable. > > glob works well most of the time: > @files = </directory/goes/here/*>; > But it has problems with large numbers of files. And the problems will > cause it to fail badly. > > The other is to opendir and read in a loop. > > In either case you need to remove the '.' and '..' entries: > > @files = grep {! /^\./} </directory/goes/here/*> > > or something like that. > > I should warn you, not only is this untested code, but I haven't even > had my coffee yet. > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > >