title: Perl Parsing Without Package
body: <p>I have a csv file containing data that I would like to parse and store into some data structure to print onto the screen. I don't have options to install any packages or modules that aren't pre-installed. I am familiar with CSV text mod but cannot use it so I have to do this manually.</p>
  
  <p>The data looks like this:</p>
  
  <pre><code>Name,Age,Weight,Target  
  April,     23,    134,    90  
  Jenna,     45,    156,    90  
  Matt,      12,    90,     90  
  Aaron,     34,    190,    90  
  Daniel,    22,    188,    90  
  </code></pre>
  
  <p>Here is what I have so far, but it simply stores all the data into an array and prints it out.</p>
  
  <pre><code>use strict;
  use warnings;
  use Data::Dumper;
  
  my $file = "file.csv";
  
  my %people;
  my @data;
  
  open my $fh, $file or die "Could not open $file: $!";
  while (my $line = &lt;$fh&gt;) {
      chomp $line;
      my @fields = split(/,/, $line);
      push @data, @fields;
  }
  close $fh;
  
  print join(", ", @data);
  </code></pre>
  
  <p>This gives an output like:</p>
  
  <pre><code>Name, Age, Weight, Target, April        ,          23,       134,     90, 
  </code></pre>
  
  <p>The spacing is due to the csv columns being spaced out. The header line has no spaces. I would like a more organized way of storing each columns values and then printing them out on the screen.</p>