Per RFC792 (http://www.faqs.org/rfcs/rfc792.html):
"The checksum is the 16-bit
sum of the ICMP message starting with the ICMP Type. For computing the checksum , the checksum field should be zero. This checksum may be replaced in the future."
Therefore, simply replace your '$chk += $short;' with '$chk ^= $short;' and it should work.
BTW: Thanks for the code! :-)
Happy Hacking!