Go Back   Velocity Reviews > Newsgroups > PERL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

PERL - Re: Can perl find strings over multiple lines?

 
Thread Tools Search this Thread
Old 11-20-2006, 08:58 PM   #1
Default Re: Can perl find strings over multiple lines?


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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump