RE: about readdir call

[email protected] ("Rajnikant")
Newsgroups perl.beginners
Message-ID <[email protected]>
Thanks Thomas... :)
It helped. 


~~~~~~~~~~~~~~~~~~~~
Thanks and Best regards,
~ Rajnikant
Software Engg.
Persistent Sys. Ltd.
Ph. +91 98222 04088

-----Original Message-----
From: Thomas Bätzler [mailto:[email protected]] 
Sent: Thursday, June 05, 2008 5:50 PM
To: [email protected]
Cc: Rajnikant
Subject: RE: about readdir call

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

--
To unsubscribe, e-mail: [email protected] For additional
commands, e-mail: [email protected] http://learn.perl.org/



DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.
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.