RICHARDS, JIM wrote: > I am trying to compare files names listed in a file to the actual > files in a directory. My code is as follows: > > > > Opendir(DIR,"name"); > > @files=readdir(DIR); > > > > Open(IN,"<fileList"); > > > > While(<IN>) { > > If(/^pattern/) { > > moveFile($_); > > } > > } > > > > Close(IN); > > > > Sub moveFile() { > > My [EMAIL PROTECTED]; > > Foreach(@files) { > > If(/$src/) { Since you are using $src as the pattern, it will take any slashes it finds and take something like abc\g and look for abcg since a \ in pattern takes whatever the next character is. So even thouhg you see abc\g, the pattern is looking for abcg. Wrap the pattern in \Q$src\E which turns off any of the special characters.
Wags ;) > > Print "$_\n"; > > } > > } > > } > > > > > > I know this is not the most efficient, but I do not understand why the > statement if(/$src/) is never true? Does not seem the $src is > interpolated correctly for the match. > > Why is this happening? How can it be fixed? > > > > Thanks in advance!!! > > > > Jim ******************************************************* This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. ******************************************************* -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>