title: How to write the initial YAML file?
body: <p>I have a hash <code>%h</code> which I would like to save as YAML.</p>
  
  <pre><code>#!/usr/bin/perl
  
  use warnings;
  use strict;
  
  my %h = ();
  
  # -----
  
  use YAML::Syck;
  my $y = YAML::Syck::LoadFile('have_seen.yaml');
  
  $y-&gt;%h ???
  
  my $yaml = YAML::Syck::Dump($y);
  $yaml::Syck::ImplicitUnicode = 1;
  
  open F, "&gt;have_seen.yaml" or die $!;
  print F $yaml . "---\n";
  close F;
  </code></pre>
  
  <p>But it seams like a chicken and egg problem.</p>
  
  <p>How do I write the yaml file for the first time, so it can be read?</p>
  
  <p><strong>Update</strong>: Based on the accepted answer was the solution</p>
  
  <pre><code>#!/usr/bin/perl
  
  use warnings;
  use strict;
  use YAML::Syck;
  use Data::Dumper;
  
  my $first_time = 1;
  
  if ($first_time) {
  
      my %h = ("1" =&gt; 2);
  
      open F, '&gt;', 'seen.yaml';
      print F YAML::Syck::Dump(\%h);
      close F;
  
  } else {
  
      my $h = YAML::Syck::LoadFile('seen.yaml');
  
      $h-&gt;{"3"} = 4;
  
      print Dumper $h;
  
      my $yaml = YAML::Syck::Dump($h);
      $yaml::Syck::ImplicitUnicode = 1;
  
      open F, "&gt;seen.yaml" or die $!;
      print F $yaml . "---\n";
      close F;
  }
  </code></pre>