multiline regex

M

Mike Jackson

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
 
A

Anno Siegel

Mike Jackson said:
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
 
M

Mike Jackson

Anno said:
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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top