in reply to Re: IP address validation when IP is picked dynamically
in thread IP address validation when IP is picked dynamically

chomp does not have much effect. Still issue remains

[root@localhost bond]# perl ifcfgbondverification.pl Enter the absolute directory location for ifcfg files /root/office/ifcfgverification/bond FailFailFailFailFailFailFailFailFailFailFailFailFailFailFailFailFailFa +ilFailFailFailFailFailFailFailFailFailFailFailFailFailFailFailFailFai +lFailFailFailFailFailFailFailFailFailFailFailFailFailFailFailFailFail +FailFailFailFailFailFailFailFailFailFailFail[root@localhost bond]#

Replies are listed 'Best First'.
Re^3: IP address validation when IP is picked dynamically
by toolic (Bishop) on May 01, 2015 at 12:48 UTC
    chomp is needed (if the IP address is the last text on the line after the split), but it may not be a complete solution to your problem. Consider the following code:
    use warnings; use strict; use Data::Validate::IP qw(is_ipv4); while (my $line = <DATA>) { chomp $line; my($key, $parameter_value) = split("=", $line); if (is_ipv4($parameter_value)) { print $parameter_value; } else { print "Fail" } } print "\n"; __DATA__ abc=1.2.3.4

    It prints "1.2.3.4". If you comment out the chomp line, it prints "Fail".

    Maybe $parameter_value isn't what you think it is. Tip #2 from the Basic debugging checklist: print

    my($key, $parameter_value) = split("=", $line); print ">>>$parameter_value<<<\n";
Re^3: IP address validation when IP is picked dynamically
by vinoth.ree (Monsignor) on May 01, 2015 at 12:58 UTC

    Could you try the code which I posted? post us the result of the script.


    All is well. I learn by answering your questions...