title: regular expression that matches any word that starts with pre and ends in al
body: <p>The following regular expression gives me proper results when tried in Notepad++ editor but when tried with the below perl program I get wrong results. Right answer and explanation please.</p>
  
  <p>The link to file I used for testing my pattern is as follows:</p>
  
  <p>(<a href="http://sainikhil.me/stackoverflow/dictionaryWords.txt" rel="nofollow">http://sainikhil.me/stackoverflow/dictionaryWords.txt</a>)</p>
  
  <p>Regular expression: ^Pre(.*)al(\s*)$</p>
  
  <p>Perl program:</p>
  
  <pre><code>use strict;
  use warnings;
  
  sub print_matches {
      my $pattern = "^Pre(.*)al(\s*)\$";
      my $file = shift;
  
      open my $fp, $file;
  
      while(my $line = &lt;$fp&gt;) {
          if($line =~ m/$pattern/) {
              print $line;
          }
      }
  }
  
  print_matches @ARGV;
  </code></pre>