custom module and lib

--00032555adf2fb49f7049b10d70e
Content-Type: text/plain; charset=ISO-8859-1

Hello All,

I have a query regarding using lib modules

1) I've some custom modules which uses various default routines like
"Net::rsh" etc
Now, i want to pack all default routines into my lib and use that lib in my
custom modules
i.e

package MyModule;

use lib "lib/test";(here i am placing my Rsh.pm etc modules and some of my
custom modules)
use Rsh;


Is this possible???

Please let me know how to go with this approach

My motive is to create a main PM file which will call all small PM
files(custom and defaults)

Thanks in Advance!

--00032555adf2fb49f7049b10d70e--
chillidba [ So, 30 Januar 2011 15:09 ] [ ID #2054102 ]

Re: custom module and lib

On 30/01/2011 14:09, a b wrote:
>
> I have a query regarding using lib modules
>
> 1) I've some custom modules which uses various default routines like "Net::rsh" etc
>
> Now, i want to pack all default routines into my lib and use that lib
> in my custom modules i.e
>
> package MyModule;
>
> use lib "lib/test";(here i am placing my Rsh.pm etc modules and some of my
> custom modules)
> use Rsh;
>
>
> Is this possible???
>
> Please let me know how to go with this approach
>
> My motive is to create a main PM file which will call all small PM
> files(custom and defaults)

I'm not clear what you need to do. What is a 'default routine'?

At a guess you want to be able to access Net::Rsh as well as your own
custom modules, in which case you probably don't understand how 'use
lib' works, which is simply to add the path(s) you specify to the end of
the list in [at] INC where perl will search for the modules you use. That
means that, even after you have done 'use lib "lib/test"' you can still
'use Net::Rsh' and it will be found, as its location is still in [at] INC.

For instance, something like

use warnings;
use strict;

use lib 'lib/test';

use Net::Rsh;
use SpecialModule;

will find Net/Rsh.pm whereever it is on your machine, as well as
lib/test/SpecialModule.pm

If this isn't what you're looking for then please post again.

HTH,

Rob

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Rob Dixon [ So, 30 Januar 2011 16:37 ] [ ID #2054103 ]

Re: custom module and lib

On Sun, Jan 30, 2011 at 03:37:14PM +0000, Rob Dixon wrote:
> On 30/01/2011 14:09, a b wrote:
> >
> >I have a query regarding using lib modules
> >
> >1) I've some custom modules which uses various default routines like "Net::rsh" etc
> >
> >Now, i want to pack all default routines into my lib and use that lib
> >in my custom modules i.e
> >
> >package MyModule;
> >

> For instance, something like
>
> use warnings;
> use strict;
>
> use lib 'lib/test';
>
> use Net::Rsh;
> use SpecialModule;
>
> will find Net/Rsh.pm whereever it is on your machine, as well as
> lib/test/SpecialModule.pm

Well, as long as perl can see where the Net/Rsh.pm module is. Perl
won't search your entire disk for the module, but rather it will
look in well known places. :-)

You'll want to put your SpecialModule in a well known place too if you
want perl to find it. Or you can take a look at local::lib on the
CPAN which can help you with precisely this.

Jeremiah

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Jeremiah [ So, 30 Januar 2011 20:38 ] [ ID #2054104 ]

Re: custom module and lib

--0016368e327714e38a049b210723
Content-Type: text/plain; charset=ISO-8859-1

Thanks much for your response!!

Making it more clear.

I want to make tar ball which contains my perl scripts and no other
dependencies required. like Net::Rsh,Net::Telnet etc
once user untar it, he should be able to run it from anywhere without any
extra perl modules. I am thinking that might be Net::Rsh etc is not
available on target m/c

With above requirement, i want Net::Rsh like modules to be in my lib. Not
sure if i need to modify Rsh module to get rid of scoping Net::

I want to simply use this module as "use Rsh;"

Can some body let me know if i can make these modules to my lib :0

help much appeciated!!!

Regards,
a b

On Sun, Jan 30, 2011 at 9:07 PM, Rob Dixon <rob.dixon [at] gmx.com> wrote:

> On 30/01/2011 14:09, a b wrote:
>
>>
>> I have a query regarding using lib modules
>>
>> 1) I've some custom modules which uses various default routines like
>> "Net::rsh" etc
>>
>> Now, i want to pack all default routines into my lib and use that lib
>> in my custom modules i.e
>>
>> package MyModule;
>>
>> use lib "lib/test";(here i am placing my Rsh.pm etc modules and some of my
>> custom modules)
>> use Rsh;
>>
>>
>> Is this possible???
>>
>> Please let me know how to go with this approach
>>
>> My motive is to create a main PM file which will call all small PM
>> files(custom and defaults)
>>
>
> I'm not clear what you need to do. What is a 'default routine'?
>
> At a guess you want to be able to access Net::Rsh as well as your own
> custom modules, in which case you probably don't understand how 'use lib'
> works, which is simply to add the path(s) you specify to the end of the list
> in [at] INC where perl will search for the modules you use. That means that,
> even after you have done 'use lib "lib/test"' you can still 'use Net::Rsh'
> and it will be found, as its location is still in [at] INC.
>
> For instance, something like
>
> use warnings;
> use strict;
>
> use lib 'lib/test';
>
> use Net::Rsh;
> use SpecialModule;
>
> will find Net/Rsh.pm whereever it is on your machine, as well as
> lib/test/SpecialModule.pm
>
> If this isn't what you're looking for then please post again.
>
> HTH,
>
> Rob
>

--0016368e327714e38a049b210723--
chillidba [ Mo, 31 Januar 2011 10:27 ] [ ID #2054258 ]

Re: custom module and lib

From: "a b" <testabhi [at] gmail.com>
> Thanks much for your response!!
>
> Making it more clear.
>
> I want to make tar ball which contains my perl scripts and no other
> dependencies required. like Net::Rsh,Net::Telnet etc
> once user untar it, he should be able to run it from anywhere without any
> extra perl modules. I am thinking that might be Net::Rsh etc is not
> available on target m/c
>
> With above requirement, i want Net::Rsh like modules to be in my lib. Not
> sure if i need to modify Rsh module to get rid of scoping Net::
>
> I want to simply use this module as "use Rsh;"
>
> Can some body let me know if i can make these modules to my lib :0
>
> help much appeciated!!!
>
> Regards,
> a b
>


This is not possible if those dependencies use C code, because they must be
compiled differently depending on the platform they are running on.
This is the same no matter the programming language you use. If a module
needs a .so file, under Windows it should be compiled as a .dll file.

If they are pure Perl, then you can bundle them in that tarball as a part of
that distribution.

If you want to bundle more compiled Perl modules that use C code and use
them under a specific platform and you don't need them to be portable, then
you might be interested to create/install them as .deb or .rpm packages.

I don't know (and maybe others know more about this) if it is possible to
compile Perl modules that use C code and then install them on the target
platform by just copying them on a custom location.

Octavian




--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Octavian Rasnita [ Mo, 31 Januar 2011 10:51 ] [ ID #2054259 ]

Re: custom module and lib

On 31/01/2011 09:27, a b wrote:
>
> Making it more clear.
>
> I want to make tar ball which contains my perl scripts and no other
> dependencies required. like Net::Rsh,Net::Telnet etc
> once user untar it, he should be able to run it from anywhere without any
> extra perl modules. I am thinking that might be Net::Rsh etc is not
> available on target m/c
>
> With above requirement, i want Net::Rsh like modules to be in my lib. Not
> sure if i need to modify Rsh module to get rid of scoping Net::
>
> I want to simply use this module as "use Rsh;"
>
> Can some body let me know if i can make these modules to my lib :0
>
> help much appeciated!!!

Do you have a special reason for wanting to rename Net::Rsh to Rsh? It
is a dangerous thing to do, as there may well be code that relies on the
name of the module being unchanged. In particular you will have to edit
the Rsh.pm file to say 'package Rsh', and it thereby becomes
non-standard and so a maintenance problem.

It is worth noting that, by default, the last entry in [at] INC is '.' - the
current directory - so perl will ultimately look in the same directory
as the calling program for all modules if they are not found elsewhere.
So you can simple bundle Net::Rsh in the same place as your main program
and any other modules.

HTH,

Rob

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Rob Dixon [ Mo, 31 Januar 2011 18:18 ] [ ID #2054261 ]

Re: custom module and lib

--00032555adf261d703049b61bb32
Content-Type: text/plain; charset=ISO-8859-1

Thanks a lot all for your views!! i got my solution

Regards,
a b

On Mon, Jan 31, 2011 at 10:48 PM, Rob Dixon <rob.dixon [at] gmx.com> wrote:

> On 31/01/2011 09:27, a b wrote:
>
>>
>> Making it more clear.
>>
>> I want to make tar ball which contains my perl scripts and no other
>> dependencies required. like Net::Rsh,Net::Telnet etc
>> once user untar it, he should be able to run it from anywhere without any
>> extra perl modules. I am thinking that might be Net::Rsh etc is not
>> available on target m/c
>>
>> With above requirement, i want Net::Rsh like modules to be in my lib. Not
>> sure if i need to modify Rsh module to get rid of scoping Net::
>>
>> I want to simply use this module as "use Rsh;"
>>
>> Can some body let me know if i can make these modules to my lib :0
>>
>> help much appeciated!!!
>>
>
> Do you have a special reason for wanting to rename Net::Rsh to Rsh? It is a
> dangerous thing to do, as there may well be code that relies on the name of
> the module being unchanged. In particular you will have to edit the Rsh.pm
> file to say 'package Rsh', and it thereby becomes non-standard and so a
> maintenance problem.
>
> It is worth noting that, by default, the last entry in [at] INC is '.' - the
> current directory - so perl will ultimately look in the same directory as
> the calling program for all modules if they are not found elsewhere. So you
> can simple bundle Net::Rsh in the same place as your main program and any
> other modules.
>
> HTH,
>
> Rob
>

--00032555adf261d703049b61bb32--
chillidba [ Do, 03 Februar 2011 15:39 ] [ ID #2054528 ]

Re: custom module and lib

If you got a solution, it could be helpful for those who will find this =
thread on the web if you would explain what you did.

Octavian
--
From: "a b" <testabhi [at] gmail.com>
> Thanks a lot all for your views!! i got my solution
>
> Regards,
> a b
>
> On Mon, Jan 31, 2011 at 10:48 PM, Rob Dixon <rob.dixon [at] gmx.com> wrote:
>
>> On 31/01/2011 09:27, a b wrote:
>>
>>>
>>> Making it more clear.
>>>
>>> I want to make tar ball which contains my perl scripts and no other
>>> dependencies required. like Net::Rsh,Net::Telnet etc
>>> once user untar it, he should be able to run it from anywhere =
without any
>>> extra perl modules. I am thinking that might be Net::Rsh etc is not
>>> available on target m/c
>>>
>>> With above requirement, i want Net::Rsh like modules to be in my =
lib. Not
>>> sure if i need to modify Rsh module to get rid of scoping Net::
>>>
>>> I want to simply use this module as "use Rsh;"
>>>
>>> Can some body let me know if i can make these modules to my lib :0
>>>
>>> help much appeciated!!!
>>>
>>
>> Do you have a special reason for wanting to rename Net::Rsh to Rsh? =
It is a
>> dangerous thing to do, as there may well be code that relies on the =
name of
>> the module being unchanged. In particular you will have to edit the =
Rsh.pm
>> file to say 'package Rsh', and it thereby becomes non-standard and so =
a
>> maintenance problem.
>>
>> It is worth noting that, by default, the last entry in [at] INC is '.' - =
the
>> current directory - so perl will ultimately look in the same =
directory as
>> the calling program for all modules if they are not found elsewhere. =
So you
>> can simple bundle Net::Rsh in the same place as your main program and =
any
>> other modules.
>>
>> HTH,
>>
>> Rob
>>
>

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Octavian Rasnita [ Do, 03 Februar 2011 16:53 ] [ ID #2054532 ]

Re: custom module and lib

--001636c5b06fac4281049bc36c1f
Content-Type: text/plain; charset=ISO-8859-1

Hi All,

I just tweak some of the regular modules under my lib and those who denied
made it as pre-reqs

I am still fighting for my exact solution


On Thu, Feb 3, 2011 at 9:23 PM, Octavian Rasnita <orasnita [at] gmail.com> wrote:

> If you got a solution, it could be helpful for those who will find this
> thread on the web if you would explain what you did.
>
> Octavian
> --
> From: "a b" <testabhi [at] gmail.com>
> > Thanks a lot all for your views!! i got my solution
> >
> > Regards,
> > a b
> >
> > On Mon, Jan 31, 2011 at 10:48 PM, Rob Dixon <rob.dixon [at] gmx.com> wrote:
> >
> >> On 31/01/2011 09:27, a b wrote:
> >>
> >>>
> >>> Making it more clear.
> >>>
> >>> I want to make tar ball which contains my perl scripts and no other
> >>> dependencies required. like Net::Rsh,Net::Telnet etc
> >>> once user untar it, he should be able to run it from anywhere without
> any
> >>> extra perl modules. I am thinking that might be Net::Rsh etc is not
> >>> available on target m/c
> >>>
> >>> With above requirement, i want Net::Rsh like modules to be in my lib.
> Not
> >>> sure if i need to modify Rsh module to get rid of scoping Net::
> >>>
> >>> I want to simply use this module as "use Rsh;"
> >>>
> >>> Can some body let me know if i can make these modules to my lib :0
> >>>
> >>> help much appeciated!!!
> >>>
> >>
> >> Do you have a special reason for wanting to rename Net::Rsh to Rsh? It
> is a
> >> dangerous thing to do, as there may well be code that relies on the name
> of
> >> the module being unchanged. In particular you will have to edit the
> Rsh.pm
> >> file to say 'package Rsh', and it thereby becomes non-standard and so a
> >> maintenance problem.
> >>
> >> It is worth noting that, by default, the last entry in [at] INC is '.' - the
> >> current directory - so perl will ultimately look in the same directory
> as
> >> the calling program for all modules if they are not found elsewhere. So
> you
> >> can simple bundle Net::Rsh in the same place as your main program and
> any
> >> other modules.
> >>
> >> HTH,
> >>
> >> Rob
> >>
> >
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
> For additional commands, e-mail: beginners-help [at] perl.org
> http://learn.perl.org/
>
>
>

--001636c5b06fac4281049bc36c1f--
chillidba [ Di, 08 Februar 2011 12:12 ] [ ID #2054800 ]
Perl » gmane.comp.lang.perl.beginners » custom module and lib

Vorheriges Thema: text encoding
Nächstes Thema: config file modules confusion