How to distribute perl over modules
Posted: Tue Apr 23, 2013 1:58 pm
[Original came from the Nabble forum]
I want to separate my perl into files (modules) without having to create a plugin.
How do I instruct kildclient to honour 'use x;' statements? Normally this is via @PERL5LIB or @INC. I've tried setting these, but the use statements are not finding the x.pm files.
Did you set PERL5LIB before you invoked kildclient. The following works for me...
- contents of file tt.pm
package tt;
sub tttt
{
print "yyyesss\n";
}
print "tt loaded\n";
1;
- extract of contents of my file which is loaded at startup by kildclient
use Data::Dumper qw(Dumper);
use tt;
- in unix bash, assuming the tt.pm file is in the current directory
$export PERL5LIB=`pwd`
$kildclient
- in kildclient input window type
/tt::tttt()
- The output in the bash window I started kildclient is...
tt loaded
yyyesss
Thanks, I didn't want to have to set an external environment variable. I sorted it by using require rather than use as in:
The harness loaded by kildclient was:
use strict;
push @INC, "/tmp/lib";
require "testLibStub.pm";
use testLibStub; # does not work
testLibStub::makeNoise();
print "finished\n";
1;
and the stub library in a file /tmp/lib/testLibStub..pm looked like:
package testLibStub;
print "testLibStub loading\n";
sub makeNoise
{
print "noise\n";
}
1;
I want to separate my perl into files (modules) without having to create a plugin.
How do I instruct kildclient to honour 'use x;' statements? Normally this is via @PERL5LIB or @INC. I've tried setting these, but the use statements are not finding the x.pm files.
Did you set PERL5LIB before you invoked kildclient. The following works for me...
- contents of file tt.pm
package tt;
sub tttt
{
print "yyyesss\n";
}
print "tt loaded\n";
1;
- extract of contents of my file which is loaded at startup by kildclient
use Data::Dumper qw(Dumper);
use tt;
- in unix bash, assuming the tt.pm file is in the current directory
$export PERL5LIB=`pwd`
$kildclient
- in kildclient input window type
/tt::tttt()
- The output in the bash window I started kildclient is...
tt loaded
yyyesss
Thanks, I didn't want to have to set an external environment variable. I sorted it by using require rather than use as in:
The harness loaded by kildclient was:
use strict;
push @INC, "/tmp/lib";
require "testLibStub.pm";
use testLibStub; # does not work
testLibStub::makeNoise();
print "finished\n";
1;
and the stub library in a file /tmp/lib/testLibStub..pm looked like:
package testLibStub;
print "testLibStub loading\n";
sub makeNoise
{
print "noise\n";
}
1;