Perl - Moving file based upon filesize in folder

Hi

I'm trying to look through a series of directories in A folder, lets just call it A:

for example:

A/1
A/2
A/3

Etc and I wish to move the files in the folder if they are bigger than a certain size into a structure like below:

A/TooBig/1
A/TooSmall/1
A/TooBig/2
A/TooSmall/2
A/TooBig/3
A/TooSmall/3

I also need it to write the filename as it goes into the TooBig folder. I have something like this but it does'nt seem to work.. Any ideas please?

open (TooBig, "> $TooBigOutput") or die;
    my $dir = 'C:/temp/';

    opendir(DIR, $dir) or die $!;

    while (my $file = readdir(DIR)) {

  
		if ( $filesize gt 0)
{

move("c:/temp", "c:temp/Big");
print  TooBig "$filesize";
}

else {

move("c:/temp", "c:temp/Small");
}
    }

    closedir(DIR);
    exit 0;

Try this example:

use strict;
use warnings;
use File::Copy 'move';

my $dir           = 'C:/temp/';
my $TooBigOutput  = "${dir}TooBigOutput.txt";

open( my $TooBigOutput_fh, '>', $TooBigOutput ) or die "Can't open $TooBigOutput $!\n";

opendir( DIR, $dir ) or die "Can't open directory: $TooBigOutput $!\n";
while ( my $file = readdir( DIR ) ) {
  my $filesize = -s $file;
  if ( $filesize gt 0 ) {
    move( "$dir$file", "$dir/TooBig/$file" );
    print $TooBigOutput_fh "$dir$file $filesize";
  } else {
    move( "$dir$file", "$dir/TooSmall/$file" );
  }
}
closedir( DIR );
close $TooBigOutput_fh;