CC: | <bug-Config-Hosts [...] rt.cpan.org> |
Subject: | not a Config::Hosts bug, but ... |
Date: | Sun, 6 Jul 2014 23:18:21 +0000 |
To: | <roman [...] parparov.com> |
From: | <Ty_Young [...] Dell.com> |
Dell - Internal Use - Confidential
Hey Roman, I'm expecting Config::Hosts to do something differently than what I'm seeing. I've read and re-read the documentation but I can't make it work using the documentation's recommendation.
Here's what I want the code to do: for a supplied IPaddr ($modCandidate) for which we've already done a query to gather desired information ...
$modCandidateSearchResult=$hosts->query_host($modCandidate);
... then request user to supply space-separated hostnames ($enteredhostnamestomodify), and replace whatever's listed for the record's hosts with @enteredhoststomodify.
if ($enteredmodchoice eq 'h') {
print "\nEnter the associated hostname(s) separated by spaces:";
chop ($enteredhostnamestomodify = <STDIN>);
@enteredhoststomodify = split /\s+/,$enteredhostnamestomodify;
$totalhostsentered = scalar(@enteredhoststomodify);
print "here's the OLD list of hostnames: @hostnames\n";
print "here's the NEW list of hostnames entered: @enteredhoststomodify ($totalhostsentered hostnames)\n";
print "\nLook good? (y/n):";
ReadMode 'cbreak';
$modhostnamesyn=ReadKey(0);
ReadMode 'normal';
if ($modhostnamesyn eq "y") {
$hosts->update_host($modCandidate, hosts => @enteredhoststomodify, comment => $storedcomment);
$hosts->write_hosts($tmphost);
print "Modified $tmphost with new comments for $modCandidate.\n";
}
My sense is that there's something wrong with this statement:
$hosts->update_host($modCandidate, hosts => @enteredhoststomodify, comment => $storedcomment);
... but since your documentation says I can supply an array to hosts=>, I'm unsure what's wrong.
The result I get is this:
.
.
Odd number of elements in hash assignment at /usr/local/share/perl5/Config/Hosts.pm line 334, <STDIN> line 2.
.
.
Am I missing something?
Ty Young
Sr Data Protection Engineer
Data Management Team for Wolters Kluwer, USA
972-577-7957 (o) | 469-301-5821 (m)
[dell_logo]
Dell | Dedicated Infrastructure Services Delivery