Reputation: 529
i have function names in a text file
i am using it to search function definition names in a C file using Perl
CODE I used
#checks whether it has ; present in which case it becomes function declaration
if ($src_line =~ /$func\([^;]+$/)
This works for only function definitions of type
int foo(int a, int b)
But doesn't work for function:
int bar (int c, int d) #having space after function name
How do i make it work for both cases.
Upvotes: 0
Views: 64
Reputation: 4953
Then, just add \s*
(meaning: 0 space or more) to your expression:
/$func\s*\([^;]+$/
Upvotes: 3