in reply to searching an array?

A good way would be to use grep() to find if @directories contains $path.
print q[@directories has $path] if grep $_ eq $path, @directories;
But if you want to do something each time you encounter $path in @directories you might want to use this approach
foreach (grep $_ eq $path, @directories) { # your code here }
If you're reading @directories from a file you'll probably want to remove the line endings with a chomp() otherwise $path won't match.
HTH

broquaint