in reply to perl CGI
The webserver will be configured to recognize .cgi files as executable scripts and execute them rather than dish out the code source like a regular page. Or the .cgi files could exist in a directory (again configured by the webserver) to treat all files contained as executables.