Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Populating an array with contents of a directory.

by disciple (Pilgrim)
on Apr 10, 2004 at 00:37 UTC ( [id://344064]=note: print w/replies, xml ) Need Help??


in reply to Populating an array with contents of a directory.

This one only returns files, excluding directories. It doesn't pull in the size of the file, but depending on where you need it, you can get that using the -s file test operator.
#!/usr/bin/perl use strict; use warnings; my $dir = 'c:\\temp'; opendir(DIRHANDLE, $dir) or warn "Could not open directory $dir.\n"; my @dirs = grep (!/^\.\.?$/ && -f "$dir/$_", readdir(DIRHANDLE)); foreach (@dirs) { print "$_\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://344064]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-28 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found