Sorry, it's not self explanatory. Your variable names say "directory", yet you seem to be trying to read from files. You're not checking whether or not your open's were successful (something like open(....) or die "Error opening file: $!;).
Comment on Re: Question mark regarding: my @lowest_priority = <LOWEST>;