title: EXtracting sub-string in Perl?
body: <p>I have a string in a variable:</p>
  
  <pre><code>$mystr = "some text %PARTS/dir1/dir2/myfile.abc some more text";
  </code></pre>
  
  <p>Now %PARTS is literally present in the string, it is not a variable or hash.
  I want to extract the sub-string <code>%PARTS/dir1/dir2/myfile.abc</code> from it. I created the following reg expression. I am just a beginner in Perl. So please let me know if I have done anything wrong.</p>
  
  <pre><code>my $local_file = substr ($mystr, index($mystr, '%PARTS'), index($mystr, /.*%PARTS ?/));
  </code></pre>
  
  <p>I even tried this:</p>
  
  <pre><code>my $local_file = substr ($mystr, index($mystr, '%PARTS'), index($mystr, /.*%PARTS' '?/));
  </code></pre>
  
  <p>But both give nothing if I print <code>$local_file</code>.
  What might be wrong here?
  Thank You.</p>
  
  <p><strong>UPDATE:</strong> Referred the following sites for using this method:</p>
  
  <ol>
  <li><a href="http://perlmeme.org/howtos/perlfunc/substr.html" rel="nofollow noreferrer">http://perlmeme.org/howtos/perlfunc/substr.html</a> see example 1c</li>
  <li><a href="https://stackoverflow.com/questions/8256382/how-to-take-substring-of-a-given-string-until-the-first-appearance-of-specified">How to take substring of a given string until the first appearance of specified character?</a></li>
  </ol>