title: How to avoid warnings in Perl regex substitution with alternatives?
body: <p>I have this regex.</p>
  
  <pre><code>$string =~ s/(?&lt;!["\w])(\w+)(?=:)|(?&lt;=:)([\w\d\\.+=\/]+)/"$1$2"/g;
  </code></pre>
  
  <p>The regex itself works fine.</p>
  
  <p>But since I am am substituting alternatives (and globally), I always get warning that $1 or $2 is uninitialized. These warnings clutter my logfile.</p>
  
  <p>What can I do better to avoid such warning?
  Or is my best option to just turn the warning off? I doubt this.</p>
  
  <p><em>Side question: Is there possibly some better way of doing this, e.g. not using regex at all?
  What I am doing is fixing JSON where some key:value pairs do not have double quotes and JSON module does not like it when trying to decode.</em></p>