title: Script to Find CPP Macro Object and Replace Token
body: <p>Okay, I have tried to do this in Perl and have had little to no success...</p>
  
  <p>Inside of a .cpp file I have the following text...</p>
  
  <pre><code>#define VARIABLE_A    32
  </code></pre>
  
  <p>And I wish to replace this with some other number</p>
  
  <pre><code>#define VARIABLE_A    123
  </code></pre>
  
  <p>I would like to be able to run this through my command-line such as:</p>
  
  <pre><code>change_variable_a 123
  </code></pre>
  
  <p>What is the easiest way to achieve this? BASH or Perl preferred. </p>
  
  <p>The code I have now is garbage. I am going about it completely wrong trying to pass parameters through a bash script into a perl one-liner.</p>
  
  <p>Okay here is what I have. </p>
  
  <pre><code> perl -MPOSIX -pe's/(\d+)/@ARGV[0]/e if /define\s+VARIABLE_A\s+\d+/' file.h &gt; file.h.2
   mv -f file.h.2 file.h
  </code></pre>