Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
some devices do not insert a 0x infront of hex ip The result is that the ip could not be translated. Maybe this could solve the problem?!
################################################## sub Convert_IP { my($ip , $result , $crap); my($hex1 , $hex2 , $hex3 , $hex4); my($oct1 , $oct2 , $oct3 , $oct4); my($hex_ip) = $_[0] ; #========================================================= +================== # Manche Geräte schicken die hexadezimale IP-Adresse # ohne führendes "0X" welches eine Hexadezimale Zahl # kennzeichnet # Für den Fall das keine "0x" mitgeschickt wird unter # Umständen die $hex_ip als ASCII Zeichen intepretiert. # Diese Schleife wandelt das ASCII Zeichen in eine # Hexadezimale Zahl um # und setzt ein "0x" vor den String. Die so neu generierte # Hexadezimale Zahl # kann dann wiederum weiterverarbeitet werden #===================================================================== +====== if (length($hex_ip) ne '10') { my @hexadezimale_IP_Adresse_ohne_0x=unpack("H2" x length($hex_ip), pac +k("A*",$hex_ip)); unshift @hexadezimale_IP_Adresse_ohne_0x, "0x"; $hex_ip = join("", @hexadezimale_IP_Adresse_ohne_0x); $hex_ip =~ s/\s+//g; print qq~hex_ip: $hex_ip\n~; } if (substr($hex_ip,0,1) eq "") { $ip = "0.0.0.0"; print "IP: $ip\n"; } else { $hex_ip =~ s/0x//g; $hex1 = (substr $hex_ip,0,2); $hex2 = (substr $hex_ip,2,2); $hex3 = (substr $hex_ip,4,2); $hex4 = (substr $hex_ip,6,2); $oct1 = hex($hex1); $oct2 = hex($hex2); $oct3 = hex($hex3); $oct4 = hex($hex4); $ip = ("$oct1\.$oct2\.$oct3\.$oct4"); } return $ip; }

In reply to Re^2: Cisco SNMP CDP Poll by Anonymous Monk
in thread Cisco SNMP CDP Poll by fingers

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (8)
    As of 2014-10-02 08:11 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      What is your favourite meta-syntactic variable name?














      Results (51 votes), past polls