Hi, I parse a log file in Perl Tk and I have for exemple this line:

LOG_INFO : cabs41.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: 
success

I have 2 labels to display the informations:
in one I put  cabs41.col.bsf.alcatel.fr
in another I put only cabs41

My code is 

 open FILE, "< $_Globals{SYSLOG}" or die $!;
    while (<FILE>) {
        if (/([0-9a-z:]+)\s*via eth0/) {
            $_Globals{MAC_ADDR} = $1;
        } elsif (/read request for/) {
            ($_Globals{IP_ADDR}, $_Globals{INSTALL_FILE}) = 
m[:\s*(\S+):.+?(/\S+):];
            ($_Globals{CLIENT_NAME}) = $_Globals{IP_ADDR} =~ /^(\w+)/;
            #$nom = gethostbyaddr(inet_aton($_Globals{CLIENT_NAME}),AF_INET)
                #or die "je ne peux résoudre $_Globals{CLIENT_NAME} :$!\n";
            ($_Globals{BOOT_FILE}) = $_Globals{INSTALL_FILE} =~ /([\w.]+)$/;
        }
    }
    close FILE;
    
but sometines I don't have the Dns informations and I can have:
   XXXX :192.40.54.42: read request for /bootp/linux/pre2.2/linux.ram: success  
(Cygwin)
   
   so my first label will display 192.40.54.42
   but my second will display only 192 which is a nonsense.
   
   How can i do to retrieve from the ip address the name which corresponds if it 
is neccesary.
   
   with gethostbyaddr for example.
   
   Thanks 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to