![]() |
|
|
|||||||
![]() |
PERL - Re: Can perl find strings over multiple lines? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Paul Lalli wrote:
> wrote: >> Is it possible to search for strings in a file over multiple lines >> using a one-liner from the shell? > > Yes, it is. > >> What I want to do is find all the text between >> a line beginning with "--" or "-- " and >> ending with ")$" where '$' is, of course, the EOL char. >> >> I also would like to know how to find the exclusion >> so that the output produces everything but the enclosed string above. >> Is this possible with perl? > > Yes, it is. > > If you would like assistance with the demonstration of such abilities, > please read and follow the Posting Guidelines for the group. Most > specifically, please post your best attempt to solve the problem > you're having, along with a description of how your attempt is not > working sufficiently. Be sure to include example input, desired > output, and actual output. While it's always good for one to attempt to solve their own problem, I don't see why the assumption is often made that they did not do so. Further more, why are some people so concerned with that in the first place? Especially for a potentially simple answer in this case. He gave a description of what he was trying to do. You could of included an answer similar like mine )below) instead of just general guidelines and leave it at that. Do not get me wrong, your guidelines are good for general purposes, but by themselves do not really offer anything to the topic it self. It sounds to me like he could find the 's' modifier for a regex match, which cause the '.' meta char to match embedded new lines. This should to do what the OP wants (un tested): @matches = $full_text =~ m!--(.*?)\)\$!sg; Vronans |
|
|