New to Perl, and using 5.8.8
I am trying to scan all the files in a folder and determine which ones have a file size greater then zero. Eventually will delete all files in that folder using unlink that have a file size greater then zero. I wrote this script that seems to be "should" work, but when I print, it prints the files that have a file size of zero as well (prints all the files).
$testfolder = '.\test'; $testfolder =~ s/\//\\/g;
opendir Sdir, $testfolder;
@files = readdir(Sdir);
undef @newfiles;
foreach $file (@files)
{
$full_pathname = $testfolder . "/" . $file;
my ($filesize) = (stat $full_pathname)[7];
if ($filesize > 0)
{
$full_pathname = $testfolder . "/" . $file;
if (-e $full_pathname)
{
@newfiles = (@newfiles,$file1);
}
}
}
foreach $file1 (@files)
{
print "$file1\n";
}