in reply to User input compared with generated list

Try this.
while (<SUBNET> ) { chomp; if ($ip_subnet eq $_) { print "PASS\n"; } else { print "FAIL\n"; } }


Update: I realized it would probably be better to also explain what might have been wrong. When you read the subnet.list file into the SUBNET file handle each line gets written into $_ not $subnet. The (<SUBNET>) is just a shortcut for ($_ = <SUBNET>). Also I added the chomp statement to remove any newline characters that would throw off your match. Again using just chomp; is shorthand for chomp $_;.

HTH

-Prime

Replies are listed 'Best First'.
Re: Re: User input compared with generated list
by zuinc (Novice) on Apr 03, 2002 at 18:44 UTC
    I tried your suggestion even before and it didnt work. For some reason, the program returns fail equal to the number of entries found in the file containing the list of subnets. For example, if there are 100 subnets, the output would be 'FAIL' 120 times. Thanks for the advice thus far. Any other suggestions? ~Zuinc