How to take IP address as input and use it in the Xpath expressions?
When i am using it as a static input like $iptext = '10.109.25.1';
it is working fine but when i am getting the input from user i am getting error
#my $ip = <>;
#my $iptext=$ip.'';
my $query = "//nodeA/nodeB[nodeC/text() = '$iptext']/../NodeD/Name/text()";
I assume what you are forgetting is that input read with
<>
or<STDIN>
come with newlines:Documentation for
chomp
here.If you do not remove the newline, your
$query
string will contain that newline, which I assume you pass to Xpath or some such:And of course that does not work.