title: How to Write a Variable to File in Perl
body: <p>I have info contained in a variable that I need to have written to a file. My script needs to be create the file and then write to it.</p>
  
  <p>Here's my current script:</p>
  
  <pre><code>my $file_location = '/network/$custom_directory/$custom_filename';
  open(my $file "&gt;", $file_location) or die $!;
  print $file "$variable_data";
  close $file;
  </code></pre>
  
  <p>I'm getting the feeling that my script is getting hung up on the actual file creation, rather than the variable-writing process. 
  The error I get when I run the script is: 'No such file or directory' at the line where I try to open the file.</p>