Re: Reading a config file and exporting it updated with the new/changes values in the same format.

2014-03-03 Thread Shlomi Fish
Hello Wernher, On Sun, 2 Mar 2014 21:42:00 +0200 Wernher Eksteen wrote: > Hi Everyone, > > I need your help with this one please. > > I have a config file that is written/updated with a Python based web front > end tool. I would like to add/remove hosts to/from this config file using > Perl. >

Re: Reading a config file and exporting it updated with the new/changes values in the same format.

2014-03-03 Thread Wernher Eksteen
Hi Shlomi, Thank you for the pointers. I do want to learn Python as well when I get a chance. This "framework" I'm writing now will automate things to a great extend eventually freeing up loads of my daily operations time so I can focus on more interesting things. I'm really not expecting the cod

Re: Reading a config file and exporting it updated with the new/changes values in the same format.

2014-03-03 Thread Jim Gibson
On Mar 3, 2014, at 8:47 AM, Wernher Eksteen wrote: > Hi Shlomi, > > Thank you for the pointers. I do want to learn Python as well when I get a > chance. This "framework" I'm writing now will automate things to a great > extend eventually freeing up loads of my daily operations time so I can fo

return just a match from an array without changing the array

2014-03-03 Thread shawn wilson
So, when I do this: my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0]; I get a full line and not just the capture: # ARIN WHOIS data and services are subject to the Terms of Use When I do this: my $src = (grep {s/.*(ARIN|APNIC).*(\n)?/$1/} @ret)[0]; I get just the match but it also alters

Re: return just a match from an array without changing the array

2014-03-03 Thread Ken Slater
I think you want to use 'map' instead of grep. HTH, Ken On Mon, Mar 3, 2014 at 6:35 PM, shawn wilson wrote: > So, when I do this: > my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0]; > I get a full line and not just the capture: > # ARIN WHOIS data and services are subject to the Terms o

Re: return just a match from an array without changing the array

2014-03-03 Thread Shawn H Corey
On Mon, 3 Mar 2014 18:35:55 -0500 shawn wilson wrote: > So, when I do this: > my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0]; > I get a full line and not just the capture: > # ARIN WHOIS data and services are subject to the Terms of Use If you can't figure out what's wrong, neither wil

Re: Reading a config file and exporting it updated with the new/changes values in the same format.

2014-03-03 Thread Wernher Eksteen
Hi Jim, The format of the config file is like this: *Config file example1:* For one host in this case named hostname1 belonging to 4 contactgroups (group1 to group4), < begin config file example 1 > host_contactgroups += [ ( 'group1', ['hostname1'] ), ( 'group2', ['h

Re: Reading a config file and exporting it updated with the new/changes values in the same format.

2014-03-03 Thread Wernher Eksteen
So, based on the config examples I gave above, the Perl script I'm writing will do the following: 1. Read the existing config file and determine the following: - How many hosts are there and what are their names. - What are the contactgroups and tag_criticality values for each host ie: "prod" or "