CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Win32 Programming Help:
listing directory content

 



hardigunawan
Deleted

Oct 10, 2000, 7:02 AM

Post #1 of 2 (2204 views)
listing directory content Can't Post

i'm new to perl. i would like to know what to code in order to list a directory contents. but i only would like to see the directory entries, not file entries.


brian.hayes
User

Oct 10, 2000, 6:06 PM

Post #2 of 2 (2204 views)
Re: listing directory content [In reply to] Can't Post

Try this, it is out of the online help this is installed with perl.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


use File::Listing;
for (parse_dir(`ls -l`)) {
($name, $type, $size, $mtime, $mode) = @$_;
next if $type ne 'f'; # plain file
#...
}
# directory listing can also be read from a file
open(LISTING, "zcat ls-lR.gz|");
$dir = parse_dir(\*LISTING, '+0000');
</pre><HR></BLOCKQUOTE>

Brian Hayes


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives