Page 1 of 1

How to distribute perl over modules

Posted: Tue Apr 23, 2013 1:58 pm
by rumex
[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;

Re: How to distribute perl over modules

Posted: Tue Apr 23, 2013 3:12 pm
by jmud
So. You want one KildClient plugin, but several Perl modules, yes?

This is how I did it:

Code: Select all

package jmud;
#: Version: 1.0.13 22-04-13
#: Description: JMud plugin for Kildclient (and other compatible hosts)
#: Author: A S Lewis
 
...

use strict;
use diagnostics;
use warnings;

BEGIN {

    # Minimum standards for Perl
    require 5.008;

    # Get the JMud directory
    require File::Basename;
    my $dir = File::Basename::dirname(__FILE__);

    # Put all JMud directories, and all subdirectories which contain Perl modules which form part of
    #   this script, into @INC
    push (@INC,
        $dir,                       # jmud.pl
        $dir . '/include',          # Most of the .pm modules
        $dir . '/jbasiclib',        # JBasic gets its own directory...
        $dir . '/jbasiclib/JBasic', # ...and subdirectory
#       $dir . '/public',           # Examples of how to write .pm modules for yourself
        $dir . '/private',          # .pm modules that you write yourself go here
    );

    # Load JMud modules from '/include'
    require automap;
    require commands;
    require definitions;
    require editwin;
    require generics;
    require gui;
    require mainloop;
    require mudmodel;
    require objects;
    require setup;
    require tasks;
    require templates;
    require wrapper;
    # Load JBasic modules from '/jbasiclib' and '/jbasiclib/JBasic'
    require JBasic;
    require Expression;
    require Function;
    require Statement;
    require Subroutine;
    require Variable;
    # Load JMud modules from '/public'
#   require public;
    # Load JMud modules from '/private' (if commented out, the call to &jmud::privateSetup in
    #   &start must also be commented out)
    require private;
}

Re: How to distribute perl over modules

Posted: Thu Jun 27, 2013 10:04 pm
by rumex
nice, thanks

How to distribute perl over modules

Posted: Wed May 07, 2014 3:20 pm
by AwamaprCB
Hi Subba Rao,
By using adlicmgr, Ive added the required modules. I notice that, by using it, we can not remove any licence. Also in the last, its message that, another task need to done, but didnt tell that, what is that task.

Thanks for your help.
Rakesh