in reply to YAML and perl

You don't show the code that is problematic, so it is somewhat hard to give you concrete advice.

I recommend the following approach:

  1. Load the existing YAML file into a data structure.
  2. Add your data to the data structure.
  3. Write the data structure to a new YAML file.
  4. Rename the new YAML file over the old YAML file.