in reply to searching an array?
But if you want to do something each time you encounter $path in @directories you might want to use this approachprint q[@directories has $path] if grep $_ eq $path, @directories;
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.foreach (grep $_ eq $path, @directories) { # your code here }
broquaint
|
|---|