[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Using grep on a list of filenames.



Recently I was using grep in a function to check if a file in one directory
has a cooresponding file in another directory in this way:

$InList=grep(/$filename/,@directorylist);

The function then returns $InList.  So far, this works great except in
certain cases for reasons I don't quite understand.

I have one file named "1220-1220+21.56@2.D" which does contain a file of the
same name in the other directory, yet the grep function will not catch it.
If I rewrite the function using a foreach statement and compare $filename
to every name in @directorylist, it works fine (but takes a lot longer, since
I'm working on filesets containing more than 500 files each).

Can anyone explain this behaviour? I'm using the MacPerl 5.07 application.
BTW If it helps, the original $filename contains a different extension
(i.e. .T instead of .D) I change this before I call the grep function and I
printed
it to STDOUT to make sure it was done correctly.

Thanks,
Louis