Searching line by line in perl from root.
Hi,
I am searching the pattern and printing the filename and linenumber using the below code. Code:
open $INPUT, '<', $filename; It works fine, but when i tried searching from root (/) it is giving below error. Quote:
The search pattern I am giving is Code:
$search_pattern = 'fnOpen\(([\w&\*\s]+)\,([\w&\*\s]+)\)'; |
I'm not certain...
But it is possible that due to the reinterpretation of the pattern that the & character in the pattern is causing a function call. You might try using the pattern: 'fnOpen\(([\w\&\*\s]+)\,([\w\&\*\s]+)\)' The & is generally used to cause the perl interpreter to treat the following token to be a function. This doesn't quite feel right to me, but then I've not had to use the & character within a character class before. One other question, why are you trying to set $1 and $2 (the unescaped "()") to the parameter names of the function being searched for? |
Quote:
The problem persists even if i use a simple search pattern. Like if I use $search_pattern= "Install" and do a find from a root. I found the problem is because of the follow (use to resolve symbolic links) used in find command. It works fine now without follow but the find doesnt resolve the symbolic links :(. Sorry I forgot to paste the whole code. Quote:
my $INPUT; my $filename; my $filename= $File::Find::name; return unless -f open $INPUT, '<', $filename; while (my $line = <$INPUT>) { $line =~ /$search_pattern/ && print $filename, ":", $.,":",$line; } close($INPUT); } |
To me, that would sound like a bug in find.
I scanned it and didn't see anything that would change the global pattern match operators - but I could have missed it. |
All times are GMT -5. The time now is 12:38 AM. |