title: Bash variable in rename regex
body: <p>I'm writing a bash script to rename files names and using command </p>
  
  <pre><code>rename 's/\d+/sprintf("%02d", $&amp;)/e' *
  </code></pre>
  
  <p>But would like to replace "%02d" with something like "%0"$var"d" thus replacing '2' with $var but it seems like it doesn't work and I'm not well versed in regex and how to use escape \ and would like help </p>