#/usr/local/bin/perl # Creates a list of all subnets $sn = 0xffff & system("ypcat hosts | cut -f1-3 -d \".\" | sort -u | sort -k 1n,1 n -k 2n,2n -k 3n,3n -t \".\" -r>subnets.list"); # User is prompted to anter an IP address open(CHECK, ">check.list") || die "ERROR! This file cannot be created!\n"; print "Enter an IP address.\n"; $ip = ; chomp ($ip); $partial = rindex($ip, "."); $ip_subnet = substr($ip, 0, $partial); chomp ($ip_subnet); print CHECK "$ip_subnet\n"; # Checkpoint - prints subnet # Match entered subnet to active subnet list open(SUBNET, "subnets.list") || die "Unable to open file: subnets.list\n"; while ( ) { if ($ip_subnet eq $subnet) { print "PASS\n"; } else { print "FAIL\n"; } }