Question about the Velocity

Dear all,
After MD simulation, I have got a xtd file.
Now I would like to print out the velocity of secleted atoms.
Here are my perl script:
User-added image

But the output of this script is these:
User-added image

What's the problem?
Thank.
Yours
CHENG Xu