RE: about readdir call

[email protected] (Thomas Bätzler)
Newsgroups perl.beginners
Message-ID <[email protected]>
Rajnikant <[email protected]> asked:
> I'm reading one directory using readdir call. but I'm getting 
> different output from that I got by running ls -l command on 
> same directory manually. Following is the snippet I'm using:
>  

#!/usr/bin/perl -w

$dirname = '/test_dir';
opendir ( DIR, $dirname ) || die "Error in opening dir $dirname\n";

foreach my $filename (sort grep { !/^\.\.?$/ } readdir(DIR)){
  print("$filename\n")
}

closedir(DIR);

__END__

HTH,
Thomas
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.