[ale] Perl binary -> hex

Christopher Fowler cfowler at outpostsentinel.com
Tue May 18 17:51:44 EDT 2004


I've got a smal UDP server written in perl that receives data via UDP. 
This data is in binary format.  I need to convert that data to a string
that is a hex representation and then I need to be able to convert back
to the original data.  How can I do this?

Here is some code that I have:

while (1) {
        my $data =undef ;
        ($hispaddr = recv(SOCKET, $data, 1024, 0))        || die "recv:
$!";
        ($port, $hisiaddr) = sockaddr_in($hispaddr);
        do {
                use bytes;
                print length($data)."\n";
        }
}


I've tried using a for loop to walk the $data byte by byte but that does
not seem to work.




More information about the Ale mailing list