Question of Perl Script

Dear all,

After MD simulation, I have got a xtd trajectory file in my project document.

Now I would like to create a new one via scripting, loop over each frame,  copy the contents to a temporary document, delete the atoms that you  don't want from the temporary document and append it to the new new  trajectory and repeat for all frames.

How can I do that?

How to write the perl script document?

Thanks.

Best regards,

                                                                   Yours

                                                                        CHENG Xu