title: Perl- How do I insert a space before each capital letter except for the first occurrence or existing?
body: <p>I have a string like:</p>
  
  <pre><code> SomeCamel WasEnteringText
  </code></pre>
  
  <p>I have found various means of splitting up the string and inserting spaces with php str_replace but, i need it in perl.</p>
  
  <p>Sometimes there may be a space before the string, sometimes not. Sometimes there will be a space in the string but, sometimes not.</p>
  
  <p>I tried:</p>
  
  <pre><code>    my $camel = "SomeCamel WasEnteringText";
      #or
      my $camel = " SomeCamel WasEntering Text";
      $camel =~ s/^[A-Z]/\s[A-Z]/g;
      #and
      $camel =~ s/([\w']+)/\u$1/g;
  </code></pre>
  
  <p>and many more combinations of =~s//g; after much reading.</p>
  
  <p>I need a guru to direct this camel towards an oasis of answers.</p>
  
  <p>OK, based on the input below I now have:</p>
  
  <pre><code>$camel =~ s/([A-Z])/ $1/g;
  $camel =~ s/^ //; # Strip out starting whitespace
  $camel =~ s/([^[:space:]]+)/\u$1/g;
  </code></pre>
  
  <p>Which gets it done but seems excessive. Works though.</p>