Skip Menu |

This queue is for tickets about the Config-Hosts CPAN distribution.

Report information
The Basics
Id: 97002
Status: rejected
Worked: 1 min
Priority: 0/
Queue: Config-Hosts

People
Owner: cpan [...] parparov.com
Requestors: Ty_Young [...] Dell.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.03



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
Download image001.jpg
image/jpeg 2.5k
image001.jpg
CC: <roman [...] parparov.com>
Subject: RE: [rt.cpan.org #97002] AutoReply: not a Config::Hosts bug, but ...
Date: Sun, 6 Jul 2014 23:28:27 +0000
To: <bug-Config-Hosts [...] rt.cpan.org>
From: <Ty_Young [...] Dell.com>
Dell - Internal Use - Confidential Nevermind, this is resolved. I did not include square brackets around @enteredhoststomodify. Show quoted text
-----Original Message----- From: Bugs in Config-Hosts via RT [mailto:bug-Config-Hosts@rt.cpan.org] Sent: Sunday, July 06, 2014 6:19 PM To: Young, Ty Subject: [rt.cpan.org #97002] AutoReply: not a Config::Hosts bug, but ... Greetings, This message has been automatically generated in response to the creation of a trouble ticket regarding: "not a Config::Hosts bug, but ... ", a summary of which appears below. There is no need to reply to this message right now. Your ticket has been assigned an ID of [rt.cpan.org #97002]. Your ticket is accessible on the web at: https://rt.cpan.org/Ticket/Display.html?id=97002 Please include the string: [rt.cpan.org #97002] in the subject line of all future correspondence about this issue. To do so, you may reply to this message. Thank you, bug-Config-Hosts@rt.cpan.org ------------------------------------------------------------------------- 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 = ); @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, 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
Hi Ty, You should specify an ARRAYREF of hosts, not an ARRAY. The documentation says so. Thanks, Roman. On Sun Jul 06 16:18:47 2014, Ty_Young@Dell.com wrote: Show quoted text
> 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