in reply to file check loop

next unless {-d "$ldir/$name"};
I don't think you want the braces there. Try:
next unless -d "$ldir/$name";

Also, I think you should change:

my @races = undef;

to:

my @races;

Tip #4 from the Basic debugging checklist: After your 1st while loop, add:

use Data::Dumper; print Dumper(\@races);