title: How to check and delete a symlink if it exists, using Perl?
body: <pre><code>if (-e "$ENV{MYHOME}/link") {
      system("rm $ENV{MYHOME}/link");
  }
  </code></pre>
  
  <p>This is the code being used to check if a symlink exists and remove it if it does.</p>
  
  <p>I am tracking a bug where this code does not work. I have not been able to figure it out as of now, but what is happening is that this code is unable to remove the symlink, which results in a 'File exists' error down the line.</p>
  
  <p>I wanted to check if there is some fundamental flaw with this technique? I also read about <a href="http://perldoc.perl.org/functions/unlink.html" rel="noreferrer">http://perldoc.perl.org/functions/unlink.html</a> but would like to know if the current approach is not recommended due to some reason?</p>