title: What is the difference between perl as a language and CGI scripts?
body: <p>I am learning Perl and trying to understand the difference between Perl and CGI. I found some definition from <a href="http://www.tutorialspoint.com/perl/perl_cgi.htm" rel="nofollow">this website </a> which says that,<br/></p>
  
  <blockquote>
    <p>"It is possible to set up the HTTP server so that whenever a file
    in a certain directory is requested that file is not sent back;
    instead it is executed as a program, and whatever that program outputs
    is sent back for your browser to display. This function is called the
    Common Gateway Interface or CGI and the programs are called CGI
    scripts."</p>
  </blockquote>
  
  <p>So my question is, not only CGI script will be sent as a executed file, all other server script languages will be sent as executed file from the HTTP server.So, what is the main purpose of CGI?</p>
  
  <p>I eagerly want to know the answer since I am really very confused. This question might be stupid one but I need to know the answer. </p>
  
  <p>For example:</p>
  
  <pre><code>#!/usr/bin/perl
  
  print "Content-type:text/html\r\n\r\n";
  print '&lt;html&gt;';
  print '&lt;head&gt;';
  print '&lt;title&gt;Hello Word - First CGI Program&lt;/title&gt;';
  print '&lt;/head&gt;';
  print '&lt;body&gt;';
  print '&lt;h2&gt;Hello Word! This is my first CGI program&lt;/h2&gt;';
  print '&lt;/body&gt;';
  print '&lt;/html&gt;';
  
  1;
  </code></pre>
  
  <p>If I save it in both <code>.pl</code> and <code>.cgi</code> extension and run both the programs, I get the same output. Then what would be the difference between cgi script and perl ?. </p>