Also, use strict and use warnings may provide useful information. You should add some error checking to opendir. Take a look anyway for an example of the error checking. It doesn't return a list! My apologies - it does in list context. Grep looks for the value in $_, which are filenames that end in. Is it not printing because we are acutally grepping for the name of the xml files and not the content in it.? I have an xml file with /load.c# in it,am expecting the grep to print it. 56 I want to search for a string of text in all files in a directory (and not its subdirectories I know the -r option does that, but that is not what I want). 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.)Ģ.xml files print fine at the line mentioned but the grep fails to print anything. grep -r 'gap' /u/user/.History/ /u/user/.History/server/user: /u/user/.History/server/user: This mostly worked except when files have strange characters listing the file name but not showing the match. Updated to fix misspelling in the regex in the 3rd paragraph. 1 I was trying to search multiple files for a string like this. 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.īut 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?Īlso, 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?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |