in reply to Grep on a list of files in directory

You need to heed the point in the first reply about checking the return value from opendir, because the other reply (about the backslash problem) is probably causing opendir to fail.

But your description is confusing; in the code snippet you say "All the xml files print fine", but at the end you say "why isn't the code printing anything...?" Is it printing xml file names or not?

Also, why are you specifically looking for strings containing '/load.c#' (the regex in the 2nd grep call) in a list of file names that end with ".xml" extensions? Do you actually have xml files with '/' and '#' (and "load.c" in between) as part of the file names?

Updated to fix misspelling in the regex in the 3rd paragraph. Also, what is the relevance of the thread title? That is, how does anything in the OP relate to "Dereferencing a hash"? (I didn't see any hashes in the OP...)

Replies are listed 'Best First'.
Re^2: Deferencing a hash
by iphone (Beadle) on Oct 29, 2010 at 05:03 UTC

    1.Fixed the title 2.xml files print fine at the line mentioned but the grep fails to print anything. i have an xml file with /load.c# in it,am expecting the grep to print it. Is it not printing because we are acutally grepping for the name of the xml files and not the content in it.????

      Yes. Grep looks for the value in $_, which are filenames that end in .xml .