title: Check if directory exists in ~/ using Perl
body: <p>I noticed strange behavior of the <code>-d</code> flag to check if a file is a directory and if the directory exists. It behaves differently when using <code>~/my_dir</code> as my path.</p>
  
  <p>The following code will return false, even though the directory <code>my_dir</code> exists, but if I'll change it to a full path like <code>/home/ricky/my_dir</code>, then the <code>if</code> statement will return true.</p>
  
  <pre><code>#!/usr/bin/perl -w
  #
  use strict;
  
  if ( -d "~/my_dir") {
      print "Found \n";
  }
  else {
      print "Not found \n";
  }
  </code></pre>
  
  <p>What's the difference?</p>