title: How can I separate a full path into directory and filename?
body: <pre><code>$a = '/etc/init/tree/errrocodr/a.txt'
  </code></pre>
  
  <p>I want to extract  <code>/etc/init/tree/errrocodr/</code>  to <code>$dir</code> and <code>a.txt</code> to <code>$file</code>.  How can I do that?</p>
  
  <p><em>(Editor's note: the original question presumed that you needed a regular expression for that.)</em></p>