title: Mock filesystem for Perl unit testing
body: <p>Is there a method or module that allows me to simulate a fake filesystem for use with Perl unit testing?</p>
  
  <p>I use a variety of <code>Test::*</code> and <code>Test::Mock*</code> modules in my unit testing, but occasionally I'd like to be able to fake a filesystem.  A simple example (and a minimum requirement) would be faking the result from the <code>-r</code> or <code>-f</code> file test operators, so that when I call objects or modules that perform file tests, I can more easily control the result.</p>
  
  <p>I know that there are all manner of ways of getting around this problem, such as creating temporary files or wrapping file tests in their own functions which can then be mocked, but sometimes it would be nice if I could just get Perl to lie to me...  So solutions that suggest rewriting the code being tested are not required ;-)</p>
  
  <p><strong>Update:</strong></p>
  
  <p>After having just found and read <a href="https://stackoverflow.com/questions/1954529/perl-mocking-d-f-and-friends-how-to-put-them-into-coreglobal">this SO question</a>, rewriting the code so that it is more testable is looking like the more sensible option.  Still, fingers crossed...</p>