some versions of perl failed to run packet.pl because the 'last' keyword can't be used outside of a loop block. this commit changes the packet dumping code to a function so we can use 'return' instead. (cherry picked from commit bf9aee1b88)
bf9aee1b88