Harold Castro wrote:
Hi,
  I'm editing a software(nagios)configuration files
and I thought it would be much easier if I could just
create a perl script to edit such files. Though I have
very little ideas coming on how to accomplish this
task. I need some tips for this one. The config file
format is like this:

define host{
    hostname      www.google.com
    ip            value1
    ...           ...
}
define host{
    hostname      value2
    ip            value2
    ...           ...
}

Its all a series of definitions enclosed with
brackets. Do you know a better solution to parse this
file such that I can edit for example the host entry
www.google.com and set its ip to a different value.

I'm thinking perhaps I could just read the file line
by line and then when it encounters the word
"hostname", look for the word next to it and then if
it is ww.google.com, and then.. that's it. I don't
know what to do next. Can you help me up on this one?
Please. Thanks


You might start here:

http://search.cpan.org/~tobeya/Nagios-Object-0.07c/

What have you tried, where did you fail?

perldoc perlopentut
perldoc -f open

Should be a starting place. You might also consider picking up "Learning Perl" from http://www.ora.com,

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to