title: Perl regex - can I say 'if character/string matches, delete it and all to right of it'?
body: <p>I have an array of strings, some of which contain the character '-'. I want to be able to search for it and for those strings that contain it I wish to delete all characters to the right of it.</p>
  
  <p>So for example if I have:</p>
  
  <pre><code>$string1 = 'home - London';
  $string2 = 'office';
  $string3 = 'friend-Manchester';
  </code></pre>
  
  <p>or something as such, then the affected strings would become:</p>
  
  <pre><code>$string1 = 'home';
  $string3 = 'friend';
  </code></pre>
  
  <p>I don't know if the white-space before the '-' would be included in the string afterwards (I don't want it as I will be comparing strings at a later point, although if it doesn't affect string comparisons then it doesn't matter). </p>
  
  <p>I do know that I can search and replace specific strings/characters using something like:</p>
  
  <pre><code>$string1 =~ s/-//
  or 
  $string1 =~ tr/-//
  </code></pre>
  
  <p>but I'm not very familiar with regular expressions in Perl so I'm not 100% sure of these. I've looked around and couldn't see anything to do with <code>'to the right of'</code> in regex. Help appreciated!</p>