This would be what the original config file would look like. Let's say I'm ready to regenerate the config file. While parsing throught the above, I want to ignore all records which contain the variable, "approvedBy", when I'm regenerating the config file.<users> <00149> <devsrv1> lastLogin Never logged in approvedBy SLS </devsrv1> <devsrv2> lastLogin Never logged in </devsrv2> </00149> </users>
Here's the code that I've got, so far:
## assume that I'm using strict, using warnings, and that all data str +uctures tus far, are populated correctly. I'm truncating the code for + the sake of brevity foreach my $inner (keys %{$users{$lastuid}}) { my $last = $users{$lastuid}{$inner}; genCtl($inner, $last, $lastuid); } print FH "\t\<\/m$newuid\>\n"; } print FH "\<\/users\>\n"; $conn->close; close FH; my $conf = new Config::General( -ConfigPath => \@path, -ConfigFile => "$ctlFile", -ExtendedAccess => 1, -InterPolateVars => 1 ); my %config = $conf->getall(); $conf->save_file("$tmpctlFile"); &procCtl; sub genCtl { my ($server, $last, $uid) = @_; print FH "\t\<$server\>\n"; print FH "\t\tlastLogin $last\n"; print FH "\t\<\/$server\>\n"; print FH "\t\tlastLogin $last\n"; print FH "\t\<\/$server\>\n"; } sub procCtl { my $tmpCtl = new Config::General( -ConfigPath => \@path, -ConfigFile => "$tmpctlFile", -ExtendedAccess => 1, -InterPolateVars => 1 ); my %tmpCtl = $tmpCtl->getall(); my $goldCtl = new Config::General( -ConfigPath => \@path, -ConfigFile => "$goldCtlFile", -ExtendedAccess => 1, -InterPolateVars => 1 ); my %goldCtl = $tmpCtl->getall(); my $tmpUser = $tmpCtl->obj("users"); my $goldUser = $goldCtl->obj("users"); foreach my $person ($tmpUser->keys("users")) { foreach my $server ($tmpUser->keys("$person")->obj("server")) { { my $approved = $tmpCtl->obj("approvedBy"); next if ($approved); } } $tmpCtl->save_file("$goldCtlFile"); } }
In reply to Comparing two config files using Config::General by blink
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |