D
Davy
Hi all,
I write a program to generate file list and directory list seperately
from a directory.
But I found the readdir run correctly only once. The second readdir
always read in a null list? why?
#-------------------------------------------------------
use strict;
use warnings;
use Data:umper;
my $path = "something";
opendir(DIR, $path);
#--- get directory list
my @dir_list = grep{-d "$path/$_"} readdir(DIR);
print $dir_list[1],"\n";
print Dumper(\@dir_list);
#--- get file list
my @file_list = grep{-f "$path/$_"} readdir(DIR);
print $file_list[1],"\n";
print Dumper(\@file_list);
closedir(DIR);
#------------------------------------------------------------------
Thanks!
Davy
I write a program to generate file list and directory list seperately
from a directory.
But I found the readdir run correctly only once. The second readdir
always read in a null list? why?
#-------------------------------------------------------
use strict;
use warnings;
use Data:umper;
my $path = "something";
opendir(DIR, $path);
#--- get directory list
my @dir_list = grep{-d "$path/$_"} readdir(DIR);
print $dir_list[1],"\n";
print Dumper(\@dir_list);
#--- get file list
my @file_list = grep{-f "$path/$_"} readdir(DIR);
print $file_list[1],"\n";
print Dumper(\@file_list);
closedir(DIR);
#------------------------------------------------------------------
Thanks!
Davy