Prajith has asked for the wisdom of the Perl Monks concerning the following question:

I need to add some data in to yaml file, but I don't know how to do that using YAML modules, This is the example file content
--- exclude_domains: - xxxx.com - yyy.net
and I have an array with following contents
my @domain_array = ('ppp.com', 'yyy.com', 'mmm.com');
I want to add the array contents to yaml file after deleting the duplicate entries. If anyone can help me on this that would be great.

Replies are listed 'Best First'.
Re: YAML and perl
by Corion (Patriarch) on Nov 26, 2013 at 08:20 UTC

    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.