in reply to Strawberry, CPAN and PERL5
Have you looked at %Config to see what has the path under your home dir? (i.e. is it the SITE paths?) -- sounds like not or it should have found them at run time.
I just dumped my config with:
Might also want to look at your CPAN config for clues: more ~/.cpan/CPAN/MyConfig.pmalias tperl='perl -I/home/myuserid/bin/lib -we'\''use strict; use P;' tperl use Config; use Data::Dumper; my $dmp = Data::Dumper->new([\%Config], [ "Config" ]); $dmp->Indent(1)->Deepcopy(0)->Sortkeys(1)->Deparse(1)->Purity(1)->Quot +ekeys(0); printf "%s\n", $dmp->Dump;'
The other thing to do would be to create a 'lib' dir under your executable and add the relative path at runtime:
For conditional compilation, I used something like:use FindBin qw($Bin); $FindBin::Bin =~ s{/bin/lib/?$}{/bin}; use lib ($FindBin::Bin . "/lib", $ENV{HOME} . "/bin/lib");
Switches will check if "-DNODEBUG" is on the command line, if so, it will call the first eval, otherwise the end.#!/usr/bin/perl use warnings; use strict; use P; use parent 'Switches'; ## example of a PERL compile-time constant ## based on a command line argument "-NODEBUG" ## using 'Switches' & BEGIN ## to run, place "-DNODEBUG" on the command line. (law) BEGIN { Switches->process_options({DNODEBUG => { act => [ sub { eval '# line '.__LINE__.' "'.__FILE__.'" use constant "_NODEBUG_"=>1;'; $@ && P::Pe("eval: %s\n", $@); } ], } }, \@ARGV); eval 'use constant _NODEBUG_ => undef;' unless *main::_NODEBUG_{CODE +}; } sub declared ($) { use constant 1.01; # note: needed for "declared", belo +w my ($name, $pkg) = (shift, caller); # prepend module name (must be a full-name) $name = q(main) . $name if '::' eq substr $name,0,2; # use caller pkg if needed my $full_name = 0 <= index($name,'::') ? $name : $pkg.'::'.$name; $constant::declared{$full_name}; } P "_NODEBUG_ is a %s %s", declared(q(_NODEBUG_)) ? "constant" : "sub" +, P "and is %s", _NODEBUG_ ? "TRUE (devel checks disabled)." : "FALSE (devel checks enabled)."
The constant created (_NODEBUG_) becomes a compile time constant that will be either '1' or 'undef'.
When working locally, create an alias or batch file to run your program with the -DNODEBUG switch. You can still take it out later, but this way if you upload your code w/o removing your custom code, it won't get activated.
Since _NODEBUG_ is a compile time constant, perl should either not include or include your debug code at runtime.
Those were just a few things I thought of off the top of my head. Hope it helps!
|
|---|