![]() |
|
good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Cisco SNMP CDP Poll (humble suggestions)by ybiC (Prior) |
on May 17, 2001 at 02:14 UTC ( #81105=note: print w/replies, xml ) | Need Help?? |
Hi fingers,
Since you asked, here's my thoughts on Cisco SNMP CDP Poll. Keep in mind that IANAJAPH, so Wiser Monks Than ITM may tell you I'm fullabeans {grin} First off - I like it, and will tweak it for use instead of some of my own Net::Telnet::Cisco-based scripts for query-only operations. Net::Snmp++ use strict; is your friend, despite sounding rather stern 8^) pod is also your friend. To my eye, that many embedded comments reduce readability Use subroutines only for modular functionality (cdp-neighbor, port count, model, etc.) A wise monk recently advised me to think of subroutines as mini-programs instead of chapters in a book. Reduces unecessary global variables, and offers potential for improved readability. Assign variable names to $_[0] and $_[1], etc early in subroutine. Improved readability?? references? Combine into chomp($community = <STDIN>); die "usage: $0 seedip" unless ( $seedhost =~ m{\d+\.\d+\.\d+\.\d+} ) Improved readability?? die "usage: $0 seedip" unless ( @ARGV == 1 ) Improved readability?? Use a CPAN module to parse IP address for legality. m/\d{1,3}.\d{1,3}.\d{1,3},\d{1,3}/ would be small improvement, checking for 1-to3-digit numbers. Mixed-case subroutine names for clarity. There are a few links to relevant posts on my homenode, near the middle in the "educate" section. ++fingers for verbish subroutine names. cheers,
Update 2001-05-17 19:45
The following adds a configurable delay:
Save results to an output file:
Use x operator to simplify code line for visual output divider, and reduce code width.
I don't have these coded yet, but could be good to:
Update 2001-05-17 20:45
In Section
Code Catacombs
|
|