note
tirwhan
<blockquote><i></i></blockquote>
<p>You're testing the files and directories as if they were in your current working directory, not the one you're examining. Here's a version that would work:</p>
<c>#!/usr/bin/perl
use strict;
use warnings;
my $dir = "D:/test_dir";
opendir( DIR, $dir);
my @file_list = readdir(DIR);
closedir(DIR);
print "Decision whether it is a file or a directory:\n";
foreach ( @file_list )
{
if( (-d "$dir/$_") )
{
print "directory: " . $_ . "\n";
}
if( (-f "$dir/$_") )
{
print "file: " . $_ . "\n";
}
}
print "\n\n";
print "Just print everything:\n";
foreach ( @file_list )
{
print $_ . "\n";
}</c>
<div class="pmsig"><div class="pmsig-237051">
<br><i>All dogma is stupid.</i>
</div></div>
833315
833315