Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Im looking for how i can send a small HEX string as a packet (most likely with socket) and then read the reply. I can do this in Ruby but in perl its getting a little hard for me to understand.

Replies are listed 'Best First'.
Re: Sending a packet and getting reply.
by Corion (Patriarch) on Jan 15, 2014 at 11:45 UTC

    So what is the Ruby code, and what problems did you encounter when moving the Ruby code to Perl?

      Here is a snippet of the ruby code. Im somewhat new to perl so i dont know how i would add it in.
      1_string = "\x97\x00\x00\x00\xAA\x00\x00\x00" socket = UDPSocket.open socket.send(1_string, 0, target_server, target_port) if select([socket], nil, nil, TIMEOUT) response = socket.recvfrom(10)

        What parts are problematic?

        As you know Ruby, I'll give you some simple/simplicistic transaltion rules for Ruby to Perl:

        • Simple variables in Perl need to start with a letter. Also, they are usually prefixed by $.
        • For opening an UDP socket, use IO::Socket::INET. It has almost the same methods as UDPSocket.
        • nil is undef in Perl.
Re: Sending a packet and getting reply.
by Anonymous Monk on Jan 15, 2014 at 11:45 UTC
    how can you do this and what is hard to understand?