<?xml version="1.0" encoding="windows-1252"?>
<node id="998052" title="Export from module in subdirectory" created="2012-10-09 14:25:53" updated="2012-10-09 14:25:53">
<type id="115">
perlquestion</type>
<author id="629110">
SuicideJunkie</author>
<data>
<field name="doctext">
&lt;p&gt;I have a module which was working great when it was in the same directory as my script.  Recently I tried to organize things and put the module in a subdirectory, but the functions are no longer being exported to main::&lt;/p&gt;
&lt;p&gt;Originally, I could &lt;c&gt;use test;&lt;/c&gt; and then just call &lt;c&gt;min()&lt;/c&gt;.&lt;/p&gt;
&lt;p&gt;After moving the file to lib/test.pm, I &lt;c&gt;use lib::test&lt;/c&gt;, and &lt;c&gt;min();&lt;/c&gt; no longer works; I had to say &lt;c&gt;test::min();&lt;/c&gt;&lt;/p&gt;
&lt;p&gt;What have I done wrong here, and how can I get my functions exported while the module is in a subdirectory?&lt;/p&gt;

test.pl
&lt;c&gt;use strict;
use warnings;
#use test;
use lib::test;

#print min(5, undef, 10, 3);
print test::min(5, undef, 10, 3);
&lt;/c&gt;

#test.pm&lt;br/&gt;
lib/test.pm
&lt;c&gt;package test;

use Exporter 'import';
our @EXPORT =  qw (min);

sub min
{
	my $best;
	foreach my $item ( @_ )
	{
		$best = $item if not defined ($best) or (defined($item) and $item &lt; $best);
	}
	return $best;
}&lt;/c&gt;
&lt;p&gt;(Treating undef as zero wasn't convenient.  This ignores undefs and returns the smallest defined value)&lt;/p&gt;</field>
</data>
</node>
