[prev in list] [next in list] [prev in thread] [next in thread]
List: perl-win32-users
Subject: Re[2]: Windows Directory
From: Christopher Taranto <christopher () tokpela ! com>
Date: 2006-03-21 17:18:02
Message-ID: 1376044438.20060321091802 () tokpela ! com
[Download RAW message or body]
Tuesday, March 21, 2006, 8:42:57 AM, you wrote:
KB> At 09:56 AM 3/21/2006, Jerry Kassebaum wrote:
>>How do I get a directory listing on a Windows machine? I think it is
>>something like:
>>
>>$direc = system `dir`;
>>print "$direc";
>><>;
KB> Try:
KB> $command = "dir c:\\your_dir;
KB> system($command);
Or, without even needing to shell...
use strict;
use warnings;
my $directory = "C:/";
opendir(my $dir, $directory) or die "Could not open directory
[$directory] - [$!]";
my @listing = grep(! /^\.+$/, readdir($dir));
closedir($dir);
foreach (@listing) {
my $listing_name = $_;
my $full_path = "$directory/$listing_name";
if (-d $full_path) {
print "[$full_path] is a directory\n";
} else {
print "[$full_path] is a file\n";
}
}
print "Done\n";
--
Best regards,
Christopher mailto:christopher@tokpela.com
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic