I am trying (for example) to identify the subset of directories (in a list of directories) that contain a file beginning with the letter 'f'.
I am using the following sample code to test:
perl -e 'use Data::Dumper; print Dumper grep(glob("$_/f*"),("dir1",
+"dir2", "dir3") )'
The idea being that the glob (evaluated) in scalar context, returns true if there is a file of form dirN/f*
However, somehow it is seemingly not being evaluated in scalar context to the extent that if dir1 contains N files beginning with 'f' then the first N directories are returned by grep even if none of the others contain a file beginning with 'f'. It is as if glob is not being evaluated in scalar context. Note even if I force glob to scalar using (scalar glob("$_/f*")), it still fails this way.
Any clue what is going wrong?
Any suggestions for alternative approaches?