Apache-ASP

 view release on metacpan or  search on metacpan

site/style.html  view on Meta::CPAN

		
		<tr>
		<td bgcolor=white><font size=-2 face="verdana" color=#993399><b><nobr>&nbsp;</nobr></b></font></td>

		<td bgcolor=white ><font face="verdana,helvetica" size=-1><b><nobr><a href="todo.html" style="text-decoration:none"><font color=#063678>TODO</font></a></nobr></b></font></td>		

		</tr>
		
		<tr>
		<td bgcolor=white><font size=-2 face="verdana" color=#993399><b><nobr>&nbsp;</nobr></b></font></td>

		<td bgcolor=white ><font face="verdana,helvetica" size=-1><b><nobr><a href="changes.html" style="text-decoration:none"><font color=#063678>CHANGES</font></a></nobr></b></font></td>		

		</tr>
		
		<tr>
		<td bgcolor=white><font size=-2 face="verdana" color=#993399><b><nobr>&nbsp;</nobr></b></font></td>

		<td bgcolor=white ><font face="verdana,helvetica" size=-1><b><nobr><a href="license.html" style="text-decoration:none"><font color=#063678>LICENSE</font></a></nobr></b></font></td>		

		</tr>
		<tr><td colspan=2><hr size=1></td></tr>
		<tr>
		<td bgcolor=white><font size=-2 face="verdana" color=#993399><b><nobr>&nbsp;</nobr></b></font></td>

		<td bgcolor=white ><font face="verdana,helvetica" size=-1><b><nobr><a href="eg/index.html" style="text-decoration:none"><font color=#063678>EXAMPLES</font></a></nobr></b></font></td>		

		</tr>
		
	</table>

	</td></tr>
	</table>

		<br>
		<center>
		<a href=http://www.apache-asp.org/><img src="powered_by_apache_asp.jpg" width="88" height="31" alt="Powered by Apache::ASP" border="0"></a>
		<br>
		<a href=http://perl.apache.org><img src="powered_by_modperl.gif" width="88" height="31" alt="Powered by ModPerl and Apache" border="0"></a>
		<br>
		<a href=http://www.perl.com><img src="rectangle_power_perl.gif" width="88" height="31" alt="Powered by Perl" border="0"></a>


</center>

</td>



<td valign=top bgcolor=white>
<font size=+0 face=verdana,arial>

<font face=verdana><font class=title size=+1 color=#555555><b>STYLE GUIDE</b></font>
<font face="courier new" size=3><pre>
</pre></font>Here are some general style guidelines.  Treat these as tips for
best practices on Apache::ASP development if you will.</font>

	<hr size=1>
	<table width=100% border=0 cellpadding=1 cellspacing=3>
	<tr>
	<td valign=top><font face="lucida console" size=-1>
	
		<tr>
		
			<td valign=top >
			<font face="lucida console" size=-1>
			<a href=#UseStrict>UseStrict</a>
			</font>
			</td>
		
			<td valign=top >
			<font face="lucida console" size=-1>
			<a href=#Use%20global.ae21f52dc>Use global.asa's Script_On* Events</a>
			</font>
			</td>
							
		</tr>
		
		<tr>
		
			<td valign=top >
			<font face="lucida console" size=-1>
			<a href=#Do%20not%20definc4a0555f>Do not define subroutines in scripts.</a>
			</font>
			</td>
		<td>&nbsp;</td>					
		</tr>
			
	</table>
	<hr size=1>
	<p>

	<p>
	<a name=UseStrict></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>UseStrict</b></font>
<font face="courier new" size=3><pre>
</pre></font>One of perl&#39;s blessings is also its bane, variables do not need to be
declared, and are by default globally scoped.  The problem with this in 
<a href=http://perl.apache.org><font size=-1 face=verdana><b>mod_perl</b></font></a> is that global variables persist from one request to another
even if a different web browser is viewing a page.  
<font face="courier new" size=3><pre>
</pre></font>To avoid this problem, perl programmers have often been advised to
add to the top of their perl scripts:
<font face="courier new" size=3><pre>
  use strict;
</pre></font>In Apache::ASP, you can do this better by setting:
<font face="courier new" size=3><pre>
  PerlSetVar UseStrict 1
</pre></font>which will cover both script &amp; global.asa compilation and will catch 
&quot;use strict&quot; errors correctly.  For perl modules, please continue to
add &quot;use strict&quot; to the top of them.
<font face="courier new" size=3><pre>
</pre></font>Because its so essential in catching hard to find errors, this 
configuration will likely become the default in some future release.
For now, keep setting it.</font>
	
	<p>
	<a name=Do%20not%20definc4a0555f></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>Do not define subroutines in scripts.</b></font>
<font face="courier new" size=3><pre>
</pre></font>DO NOT add subroutine declarations in scripts.  Apache::ASP is optimized
by compiling a script into a subroutine for faster future invocation.
Adding a subroutine definition to a script then looks like this to 
the compiler:
<font face="courier new" size=3><pre>
  sub page_script_sub {
    ...
    ... some HTML ...
    ...
    sub your_sub {
      ...
    }
    ...
  }
</pre></font>The biggest problem with subroutines defined in subroutines is the 
side effect of creating closures, which will not behave as usually
desired in a <a href=http://perl.apache.org><font size=-1 face=verdana><b>mod_perl</b></font></a> environment.  To understand more about closures,
please read up on them &amp; &quot;Nested Subroutines&quot; at:
<font face="courier new" size=3><pre>
  <a href=http://perl.apache.org/docs/general/perl_reference/perl_reference.html>http://perl.apache.org/docs/general/perl_reference/perl_reference.html</a>
</pre></font>Instead of defining subroutines in scripts, you may add them to your sites
global.asa, or you may create a perl package or module to share



( run in 0.614 second using v1.01-cache-2.11-cpan-39bf76dae61 )