Peter Fleck wrote: > This isn't 'production' code. I'm playing with this to get ready to > use the commands in a project. That's why I'm doing the same thing in > two different ways. > > I have two ways of of getting a list of file names below, working > with opendir and readdir. The second method doesn't work if the first > method is active. Commenting out the first segment gets the second > segment to work. Reversing the order also of the methods also sees > the first one only working. > > What I would guess is that I can only use the 'readdir' once in a > script. What's that about?
It's like reading through a file. Once you've read to the end, additional calls to readdir return undef (or empty list). If you want to read the files again, you can use rewinddir() to reset the pointer back to the beginning. (You can also close and reopen the dir handle.) perldoc -f rewinddir > > Thanks. > > opendir(DIR, $dirname) or die "can't opendir $dirname: $!"; > > my @filelist = readdir(DIR); > print "[EMAIL PROTECTED]: @filelist\n"; > > while (my $file = readdir(DIR)) { > print "$file\n"; > } > > closedir(DIR); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]