title: Replace and Delete when fetching some string in the same regex in perl
body: <p>My Input:</p>
  
  <pre><code>$str = 'In order to study the opportunity cost of allocating time to the less beneficial act, we need appropriate schedules of reinforcement description &lt;?processing-instruction \value{$$@@%}?&gt; list we need appropriate schedules of reinforcement';
  
  my $get_val = ($str=~m/&lt;\?processing\-instruction\s*\\value\{([^\}\?&gt;]*)\}\?&gt;/gi)[0];
  
  print $get_val;
  </code></pre>
  
  <p>However I need to delete the whole processing instruction tag while finding the same. Is it possible on the same pattern?</p>
  
  <p>I tried this however not success.</p>
  
  <pre><code>my ($get_val) = ($str=~s/&lt;\?processing\-instruction\s*\\value\{([^\}\?&gt;]*)\}\?&gt;//gi)[0];
  
  print $get_val;
  </code></pre>
  
  <p>The above output prints '1'. It would be appreciate if someone could help on this one.</p>
  
  <p>Thanks in advance.</p>