in reply to how to dir a directory that have space
given that your $source_directory contains spaces, the system command is misinterpreted:
use system(@list) form instead:`dir $source_directory /b/s /o:-d`;
system('dir', $source_directory, '/b/s', '/o:-d');
In Section
Seekers of Perl Wisdom