in reply to How to Modify Each file??

You are close. You will find the missing pieces for your code in perlfunc, there specially open, readline, close. For swapping the first words in a line look for the word 'swap' in perlre. See perlsyn for control structures.

I won't tell you more since I strongly suspect this being homework.

before copying or after copying

I have a dog, and he takes orders as spoken. It's only a matter of how I formulate them. That's how I call him: "fido, come or don't!"

And he comes, or doesn't.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}