in reply to Class-C subnet discovery/scanner

I ran podchecker on your program and received these messages:

$ podchecker 747546.pl *** WARNING: line containing nothing but whitespace in paragraph at li +ne 34 in file 747546.pl *** ERROR: =item without previous =over at line 130 in file 747546.pl *** WARNING: line containing nothing but whitespace in paragraph at li +ne 141 in file 747546.pl *** ERROR: Spurious text after =cut at line 135 in file 747546.pl *** WARNING: line containing nothing but whitespace in paragraph at li +ne 158 in file 747546.pl *** ERROR: Spurious text after =cut at line 156 in file 747546.pl *** ERROR: =item without previous =over at line 360 in file 747546.pl *** WARNING: line containing nothing but whitespace in paragraph at li +ne 378 in file 747546.pl *** ERROR: Spurious text after =cut at line 372 in file 747546.pl *** WARNING: line containing nothing but whitespace in paragraph at li +ne 485 in file 747546.pl *** ERROR: Spurious text after =cut at line 480 in file 747546.pl *** ERROR: =item without previous =over at line 527 in file 747546.pl *** WARNING: line containing nothing but whitespace in paragraph at li +ne 533 in file 747546.pl *** ERROR: =item without previous =over at line 716 in file 747546.pl *** WARNING: line containing nothing but whitespace in paragraph at li +ne 719 in file 747546.pl *** WARNING: line containing nothing but whitespace in paragraph at li +ne 721 in file 747546.pl *** ERROR: Spurious text after =cut at line 787 in file 747546.pl 747546.pl has 9 pod syntax errors.

Then I ran the compiler on it and got a syntax error:

$ perl -c 747546.pl syntax error at 747546.pl line 681, near "next "

Because you are missing a semicolon on the previous line.

191: open(CACHE_FH," < $cache"); 212: open(F,">$cache"); 425: open(FILE, ">$cache"); 677: open(CACHE_FH, "< $cache"); 700: open(F,">$cache");

Also, you should verify that open succeeded before you try to use a possibly invalid filehandle.

Update

411: stdout::debug("BroadcastPing: Read $#lines lin +es from $cache\n"); 421: stdout::debug("BroadcastPing: Writing $#keys l +ines to $cache\n"); 926: stdout::debug("read_arptable(): ARP Read: Read + $#lines lines from $arp_cachefile\n");

The variables $#lines and $#keys do not contain the number of lines, they contain the last index of the arrays @lines and @keys.   You need to use the array in scalar context to get the correct number:

stdout::debug("BroadcastPing: Read " . @lines +. " lines from $cache\n"); stdout::debug("BroadcastPing: Writing " . @key +s . " lines to $cache\n"); stdout::debug("read_arptable(): ARP Read: Read + " . @lines . " lines from $arp_cachefile\n");

Replies are listed 'Best First'.
Re^2: Class-C subnet discovery/scanner
by jbryan (Acolyte) on Mar 03, 2009 at 14:29 UTC

    I'd forgotten about podchecker - thanks! I've made it check cleanly now in podchecker.

    Ooops! I did forgot the open return value, didn't I? Fixed that now. Thanks again!

    The last index variables ($#lines, etc) - I was just being lazy and not coding ".scalar(@keys)." - instead putting $#keys inline was faster - just laziness, that's all. I've updated the code now to output less lazily. :-) Thanks again!

      I still get a warning when warnings are enabled:

      $ perl -Mwarnings -c 747546.pl Name "NetMon::Util::FH" used only once: possible typo at 747546.pl lin +e 63.
        Ahh yeah - missed that one through all the debug output. Quick and dirty fix added to the code above. (my $fh; ... sysopen($fh,...)) Thanks for the heads up.