Ruby to Perl need help converting a function
I am new to both Ruby and Perl so I am requesting a translation for the following functions. I understand how the commands work,up to the ".collect" but cant wrap my mind around what the join does and how it gets the result.
I am trying to duplicate the result of the following commands in a Perl script. The data I get back from my socket connection is " b&WjP&Wl~'jb&Wj`P&Wl~'jb&WðèP&Wl " and I am trying to convert it into hex ex(02621426570F6B06 262142657f6b66 250142657176c7e276b6 ).
Ruby Code listed below. I can attach the whole script if needed.
def hexlify(msg)
msg.split("").collect { |c| c[0].to_s(16) }.join
end
def unhexlify(msg)
msg.scan(/../).collect { |c| c.to_i(16).chr }.join
end
Thank you.
-Gregg
|