my $dirPath = 'c:\apps\c++\application'; print grep { /\Q$dirPath\E/ } ('c:\apps\c++\application\myfile.cpp');