in reply to Combine files with same extension in new file

Some general tips:

  1. use strict
  2. use warnings
  3. run in taint mode (with -T) since you'll be writing to the filesystem.

Other than that: design an algorithm first, then code it up. Have fun.