http://qs321.pair.com?node_id=1212629


in reply to This does not look like start end

I don't think we have enough information to help you here. Is it possible for you to post the script?

It is usually helpful to distill your script down to the bare minimum amount of code which still exhibits your bug.

Also, if you add use strict and use warnings to the top of your script you might get some clues from Perl itself.

Jim

Replies are listed 'Best First'.
Re^2: This does not look like start end
by Anonymous Monk on Apr 10, 2018 at 08:33 UTC

    The problematic part is this one:

    foreach my $subnet (($ip->bits() == 32)?@IPv4Subnets:@IPv6Subnets) { next if ($subnet eq ''); my @subnetInfo = split(/;/x, $subnet); if (Net::CIDR::cidrlookup($params{ip}, trim($subnetInfo[0]))) { return (1, \@subnetInfo); } }

    I have also tried to rewrite it to while cycle with the same result.

    my $number = 0; my @subnets = ($ip->bits() == 32)?@IPv4Subnets:@IPv6Subnets; while ($number < scalar @subnets) { my $subnet = @subnets[$number]; if ($subnet eq '') { $number++; next; } my @subnetInfo = split(/;/x, $subnet); if (Net::CIDR::cidrlookup($params{ip}, trim($subnetInfo[0]))) { return (1, \@subnetInfo); } else { $number++; } } return (0, "Could not find ip '$params{ip}' in subnets list");
    Funnily enough the script worked when I had incorrect comparison operator ($subnet == '') in my code (with a lot of complaining from Perl of course)