On Wednesday, June 26, 2002, at 04:16 , Nigel Peck wrote:
> For all the CPAN modules I have used so far I have simply uncompressed > them and used the .pm's as they are. Would someone be kind enough to > explain to me why I should or shouldn't use the makefile.pl and test.pl > method of installing rather than just copying the .pm's to my lib in the > correct directory? first off - before this starts to sound hostile, annoying, dogmatic, let me start by saying - you are really asking the right question! Since implicit in it is: so why is this the 'CPAN way' to put all the rest of this stuff in the tarball - that seems so extraneous at this point? The answer to which will help you understand a part and parcel of how to move along to 'just use h2xs' to build out your perl modules. { embedded in that is - so.... how should I be making perl modules in a standard way that will be easiest for the perl community. Trust me that question will come - since you started with the right form of "I found modules I can use at the CPAN" - and it will only be a matter of time before you are returning the complement.... } So My first question I have is - So How exactly do you 'use' them? without the 'installing' of them in some canonical place? I see the sentance "copying the .pm to my lib" { and yes, we have all done that..... } Granted the 'canon' is: perl Makefile.PL make make test make install which is a lot of 'typing' to do - and could be solved with a simple shell script 'installThis' - in your $ENV{HOME}/bin that would do all of that - see below - I also use say one that sets the basics for things that I am Not planning to install 'for all users' on the machine in the canonical CPAN place - which I use for testing things - see second script. So a part of the reason that we do this is the basic question is this code for me or the community? If this is something that I want to share with other people who have access to the host - then it is simpler to do the #!/usr/bin/perl -w use strict; use FOO::BAR; and have it found In the Canonical CPAN style 'site local' space rather than having to hard code in #!/usr/bin/perl -w use strict; use lib "/path/to/my/home/lib/perl"; use FOO::BAR; for all scripts that you are using - OR requiring that they all install a symbolic link in their $ENV{HOME}/lib/perl that points to yours so that their use lib "$ENV{HOME}/lib/perl"; will point in the right place.... So getting in the habit of doing what it takes to install it in the CPAN local space clearly saves you time in the long run as you don't have to go through any of that convolution in your code - and people then are more willing to like you for your cool code that you share. On the strictly technical side of the game - there is also the problem - What if this Module is using the AutoLoader to load in portions of the code when called. If you have not moved all of *.al files as required to the correct auto sub directory - you lose all the advantage of playing that - and will have fun debugging what really went wrong. If the module delivered a *.bs because there really was XS code that created a loadable module - then your *.pm files will freak in way strange ways - that will be fun to debug - as you find out that the DYNALOADER fried in really weird, rude, and socially relevant ways you have not as yet seen Perl Woof Cookies On. Assuming that you are 'old school' and still do, as I do, man DTK::WebAccess::DI704 from time to time - since your 'modules' are not in the canonical place - and would need to modify your PERL* env to have your 'use lib' stuff stuffed there - by using the standard make file approach - you would find that your man pages of the POD will be appropriately installed as well. eg: [jeeves:~/bin] drieux% perldoc DTK::WebAccess::DI704 No documentation found for "DTK::WebAccess::DI704". [jeeves:~/bin] drieux% man DTK::WebAccess::DI704 man: Formatting manual page... DTK::WebAccess:User0Contributed Perl DocuDTK::WebAccess::DI704(3) NAME DTK::WebAccess::DI704 - Get IP from DI704 SYNOPSIS use DTK::WebAccess::DI704; blah blah blah ...... and if you are like me, it is faster and simpler to code from the POD/Man with a cut and paste of the foo - than any other trick we do with the cut/paste option... { again - saves a whole BUNCH of time - if you stuff not merely the *.PM files but also all of the documentation... which you will miss if the FOO::BAR actually dragged along mere *.pod files, which you didn't 'manify' nor manuever... } Allow me the fun at this point of sharing from the dialog that bob ackerman and I have been having about 'developing perl modules' to help a part of the discussion here as well... Some here will recall the simple problem: I need to get the external DHCP IP address off of my DI704 router - so that I can do something with it - and I found this piece of python that sorta does it.... after finding that the canonical LWP::UserAgent was 'doing the wrong thing' of actually building correct HTTP headers - that caused 500 errors from DI704's "LAME!LAME!LAME!" webServerEtte, we fell back to the old drieuxIsh WebPageRipper tricks of open the socket stuff the Message At the webServerEtte read the socket, Woof the OutPut bob's solution, upon seeing the tarball - was, forgive me, less elegant than your current method - since he wanted to rip the "pm" extension off - so that he could write a simple piece of perl code that would just hall in the functions. This lead him to then modify the Perl Module to do in the functions in it what he found useful. That IS a solution. My counter to him has been: why not extend around the webFoo.pm? with a DI704.pm that does the DI704.pm specific things? So far we have been able to get to the simpler $ENV{'HOME'}/lib/perl for sticking the modules - so that he can use the simpler approach that you are mostly working of use lib "<whereWeStuffThem>"; But along the way we have looked at what h2xs gives your for free as a base line - as well as were to start tipping and tripping the light fantastic.... Now the demo code has shrunk to ### #!/usr/bin/perl -w ### use strict; ### use lib "$ENV{HOME}/lib/perl"; ### use DTK::WebAccess::DI704 qw/:all/; ### ### # demo.plx - demo Another Path ### # in short - drieux's answer to rda's ideas. ### ### die "error logging into box\n" unless (login_to_DI704box()); ### ### if ( my $ip_addr = get_RouterIP() ) { ### print "we see the far side as: <$ip_addr>\n"; ### } else { ### die "Unable to status box\n"; ### } ### ### # ginned On 25-Jun-02 ### # ### # end of the world as I knew it [EMAIL PROTECTED] all rights reserved Now the part that he 'really needs' is down to a few lines of code that he can RIP OUT of here and into the 'real code' that he needs - since he has his "$ip_addr" in place. Note that while this will work well enough on a box where there is 'just him' - he can share it with folks who would be running say - 'the family home server'.... where all the members of the family have their own Xterminal network stations.... And Gosh - installing it where the CPAN style Stuff would expect it, then he can have daemons run it..... that do not have to know about his home directory..... especially when they are running as say user 'nobody'..... So while, yes, INFESTATION UNITS, like to think that they are the only 'person' on the Computer - this Anti-Sentient LifeForm prejudice against Silicon and Algorithmic based Life Forms is NOT going to take you Far in the Galaxy MonkeyBoy!!!! Have I made myself clear? ciao drieux --- #---------------------- #!/bin/sh # simple InstallThis shell script MY_PWD=`pwd` echo "you are at ${MY_PWD}" if [ -f Makefile.PL ] then perl Makefile.PL make test make install else echo "no Makefile.PL found" fi #----------------------- ### #!/usr/bin/perl -w ### use strict; ### # ### #/home/drieux/bin/PerlInstall - you know to install stuff locally ### # ### ### my $prefix = $ENV{HOME}; ### my $lib = "$prefix/lib/perl"; ### my $man = "$prefix/man"; ### my $cmdArgs = "PREFIX=$prefix LIB=$lib "; ### $cmdArgs .= " INSTALLMAN3DIR=$man/man3 INSTALLMAN1DIR=$man/man1"; ### ### my $cmd = "perl Makefile.PL $cmdArgs"; ### ### system("make clean"); ### ### system($cmd); ### system("make test"); ### system("make install"); ### -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]