Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   multiline regex (http://www.velocityreviews.com/forums/t883068-multiline-regex.html)

Mike Jackson 10-13-2003 10:53 AM

multiline regex
 
Hi,
I would like to convert this block of text:

(app "webserver"
(ip "1.2.3.4")
(name "foo")
(host "somehost")
)


to this:

app.webserver.ip="1.2.3.4";
app.webserver.name="foo";
app.webserver.host="somehost";


and skip processing of the entire block if the top level contains a
"no", for example:

(some_condition "no"
(foo "")
(bar "")
)


Is there already some method of doing this in perl, or is this a regex
job? Any advice?

Thanks,
Mike


Anno Siegel 10-13-2003 11:54 AM

Re: multiline regex
 
Mike Jackson <mjj@isorauta.ntc.nokia.com> wrote in comp.lang.perl.misc:
> Hi,
> I would like to convert this block of text:
>
> (app "webserver"
> (ip "1.2.3.4")
> (name "foo")
> (host "somehost")
> )
>
>
> to this:
>
> app.webserver.ip="1.2.3.4";
> app.webserver.name="foo";
> app.webserver.host="somehost";
>
>
> and skip processing of the entire block if the top level contains a
> "no", for example:
>
> (some_condition "no"
> (foo "")
> (bar "")
> )
>
>
> Is there already some method of doing this in perl, or is this a regex
> job? Any advice?


What have you tried so far?

We help writing scripts, but we're not in the business of delivering
to specification.

You have nested parentheses to parse, so Text::Balanced will probably
figure in the solution.

Anno

Mike Jackson 10-13-2003 01:32 PM

Re: multiline regex
 
Anno Siegel wrote:

>
> You have nested parentheses to parse, so Text::Balanced will probably
> figure in the solution.


Hi,
That was all I asked and all I wanted to know, e.g. was there already
a module that could assist in this task, or was it purely a regex task.
Thanks for the tip :-) I'm sure that it will save me some time.

Thanks,
--
mike



All times are GMT. The time now is 09:35 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57