<?xml version="1.0" encoding="windows-1252"?>
<node id="781340" title="Re: Perl Module ending without 1;" created="2009-07-18 10:56:08" updated="2009-07-18 10:56:08">
<type id="11">
note</type>
<author id="675798">
ig</author>
<data>
<field name="doctext">
&lt;p&gt;When you [doc://use] your module, [doc://use] [doc://require]'s your module. This is explained in the documentation for [doc://use].&lt;/p&gt;

&lt;p&gt;[doc://require] includes your module by evaluating it with [doc://do]. This is explained in the documentation for [doc://require].&lt;/p&gt;

&lt;p&gt;If your module compiles successfully, [doc://do] returns the value of the last expression evaluated. When you end your module with &lt;b&gt;1;&lt;/b&gt;, this value is 1. This is explained in the documentation for [doc://do].&lt;/p&gt;

&lt;p&gt;[doc://require] checks the value returned by [doc://do] and if it is false it dies with the error &lt;i&gt;$filename did not return true value&lt;/i&gt;, where $filename is the full path name of the file being loaded (your module).&lt;/p&gt;

&lt;p&gt;So, as others have pointed out, it is not necessary that your module end with &lt;b&gt;1;&lt;/b&gt; but if you want to include it with [doc://use] or [doc://require] then the last expression evaluated must have a true value. Ending modules with &lt;b&gt;1;&lt;/b&gt; is merely a convention to ensure they return a true value.&lt;/p&gt;

&lt;p&gt;Note that you can include a module that ends with &lt;b&gt;0;&lt;/b&gt; (or any other expression that evaluates to a false value. You can't include it using [doc://use] or [doc://require], but you can use [doc://do] and ignore the return value or load the content into a scalar and use [doc://eval] to evaluate the scalar and, again, ignore the return value.&lt;/p&gt;</field>
<field name="root_node">
781320</field>
<field name="parent_node">
781320</field>
</data>
</node>
