title: how to extract the subset from a special character string using perl
body: <p>I need to get the subset of a string starting from a specific start word and end before the specified word. Store in the string variable.</p>
  
  <p>Example: <code>pre-wrap"&gt;test-for??maths/camp</code></p>
  
  <p>I need to fetch the subset.</p>
  
  <p>Expected output:  <code>test-for??maths</code></p>
  
  <p>After: <code>pre-wrap"&gt;</code> or may be starting with: <code>test</code></p>
  
  <p>and before: <code>/camp</code></p>
  
  <p>I have no clue how to achieve this in Perl.</p>
  
  <p>Here is the code I tried. The output is not coming as expected:</p>
  
  <pre><code>#!/usr/bin/perl
  
  use warnings;
  use strict;
  
  my $string = 'pre-wrap"&gt;test-for??maths/camp';
  my $quoted_substring = quotemeta($string);
  my ($quoted_substring1) = split('/camp*', $quoted_substring);
  my (undef, $substring2) = split('&gt;\s*', $quoted_substring1);
  
  print $string, "\n";
  print $substring2, "\n";
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>$ perl test.pl
  pre-wrap"&gt;test-for??maths/camp
  test\-for\?\?maths\         # but why this \ is coming
  </code></pre>