in reply to Re: How can i catch strings matching a regex across multiple lines?
in thread How can i catch strings matching a regex across multiple lines?
you can see that $id gets reinitialized upon each iteration of the loop (with each new line read)But he is reading records, not lines and therefore it is perfectly OK --even recommended-- to re-initialize $id each time through the loop.
The solution is to add the g modifier to the regex.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial Deltronics
|
|---|