regex - perl Match multiline pattern in a file -


i have program reads file line line , gets data when pattern matched.
extracts patterns like
function abc (int a, int b)
have functions like
function xyz (int a, \n
int b)

doesn't match due file being read line line.

is possible read file in better way or should use obvious technique of getting multiple lines.

you'll need read multiple lines in @ once. if file isn't large can slurp entire file in (e.g. http://www.perl.com/pub/2003/11/21/slurp.html) , use single line regex (use s option e.g. /stuff.next line/s).

editexample multiple matches* g option allows matches. 1 sample usage in while loop, each time evaluate regex next match. see perl iterate through each match more details , examples.

while($string=~/(regex)/g){     dosomething($1); } 

edit fixed error


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -