title: Using perl to split a line that may contain whitespace
body: <p>Okay, so I'm using perl to read in a file that contains some general configuration data. This data is organized into headers based on what they mean. An example follows:</p>
  
  <pre><code>[vars]
  
  # This is how we define a variable!
  $var = 10;
  $str = "Hello thar!";
  
  
  # This section contains flags which can be used to modify module behavior
  # All modules read this file and if they understand any of the flags, use them
  [flags] 
    Verbose =       true; # Notice the errant whitespace!
  
  [path]
  WinPath = default; # Keyword which loads the standard PATH as defined by the operating system. Append  with additonal values.
  LinuxPath = default;
  </code></pre>
  
  <p>Goal: Using the first line as an example "$var = 10;", I'd like to use the split function in perl to create an array that contains the characters "$var" and "10" as elements. Using another line as an example:</p>
  
  <pre><code>    Verbose    =         true;
      # Should become [Verbose, true] aka no whitespace is present
  </code></pre>
  
  <p>This is needed because I will be outputting these values to a new file (which a different piece of C++ code will read) to instantiate dictionary objects. Just to give you a little taste of what it might look like (just making it up as I go along):</p>
  
  <pre>define new dictionary
  name: [flags]
  # Start defining keys => values
  new key name: Verbose
  new value val: 10 
  # End dictionary</pre>
  
  <p>Oh, and here is the code I currently have along with what it is doing (incorrectly):</p>
  
  <pre><code>sub makeref($)
  {
      my @line = (split (/=/)); # Produces ["Verbose", "    true"];
  }
  </code></pre>
  
  <p>To answer one question, why I am not using Config::Simple, is that I originally did not know what my configuration file would look like, only what I wanted it to do. Making it up as I went along - at least what seemed sensible to me - and using perl to parse the file. </p>
  
  <p>The problem is I have some C++ code that will load the information in the config file, but since parsing in C or C++ is :( I decided to use perl. It's also a good learning exercise for me since I am new to the language. So that's the thing, this perl code is not really apart of my application, it just makes it easier for the C++ code to read the information. And, it is more readable (both the config file, and the generated file). Thanks for the feedback, it really helped.</p>