title: How to use an user input as a regex?
body: <p>I have a simple program where the user can enter a string.
  After this the user can enter a regex. I need the string to be compared against this regex.</p>
  
  <p>The following code do not work - the regex always fails.</p>
  
  <p>And I know that its maybe because I am comparing a string with a string and not a string with a regex. </p>
  
  <p>But how would you do this?</p>
  
  <pre><code>while(1){
      print "Enter a string: ";
      $input = &lt;&gt;;
      print "\nEnter a regex and see if it matches the string: ";
      $regex = &lt;&gt;;
  
      if($input =~ $regex){
          print "\nThe regex $regex matched the string $input\n\n";
      }
  }
  </code></pre>