title: How do I add data from a CSV file to an array in Perl?
body: <p>I've searched and searched online, but nothing I do seems to work. I'm aware that this is a stupidly easy question, but I'm really stuck...</p>
  
  <p>I had a directory of files, and saved the names of the directories to a CSV file. It's just made up of one column of data e.g.:</p>
  
  <pre><code>100
  101
  102
  103...
  </code></pre>
  
  <p>I used the following code to create the file (just in case its relevant):</p>
  
  <pre><code>open (my $fileh, '&gt;', '/Users/Shared/serials.csv') or die "Could not open file!";
  print $fileh `ls -1 $path`;
  close $fileh;
  print "Saved Serials!";
  </code></pre>
  
  <p>Now all I want is to read in the data in the file into an array, and then loop through each value to complete a task. I can't figure out how to do this...</p>
  
  <p>Currently I am entering the numbers manually in the code into an array, like:</p>
  
  <pre><code>@ser_list = (100,101,102,103,...);
  </code></pre>
  
  <p>As stated above, I instead want to automatically write the file names (numbers) using the <code>ls</code> command line query and read them back into the script from there. 
  If there is a way of doing this without having to make a separate file of values that would be great.</p>
  
  <p>The array is called @ser_list in the example, and from there I am reading the next $ser_num from the array and working with that in the loop.</p>
  
  <pre><code>foreach $ser_num (@ser_list) {....}
  </code></pre>
  
  <p>Thank you all in advance for your help and patience! </p>