On 14-04-04 01:11 AM, Gabor Szabo wrote:
Though on a second look, Yanick, I don't even understand what does
that code do?:)
The only weird part is the 'if' module, which is nice here to deal with
the case where we want to be able to have a custom share dir on demand,
but do the usual thing by default.
But an example always help:
$ cat share.pl
use if $ENV{MYSHARE} => 'Test::File::ShareDir', '-share' => {
-module => { split '=', $ENV{MYSHARE} }
};
use List::Util;
use File::ShareDir 'module_dir';
print module_dir( 'List::Util' );
__END__
$ perl share.pl
/usr/local/soft/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux/auto/List/Util⏎
$ env MYSHARE="List::Util=somewhere" perl share.pl
/tmp/Hem2UUJ3Dy/auto/share/module/List-Util⏎
In the first invocation, $MYSHARE is not defined, so
Test::File::ShareDir is not loaded at all and all behave as normal.
In the second invocation, $MYSHARE points to a local directory. Its
existence triggers the loading of 'Test::File::ShareDir' (because of
our use of the 'if' module), and will create a temporary sharedir with
the content of the original './somewhere' directory.
Mind you, that script is probably overkill in term of customization. I
expect that the following would do the trick just fine as long as the
local 'share' folder is the one you want to use:
$ cat share.pl
use if $ENV{MYSHARE} => 'Test::File::ShareDir', '-share' => {
-module => { My::Module => 'share' }
};
use My::Module
use File::ShareDir 'module_dir';
print module_dir( 'My::Module' );
__END__
A little clearer, or did I manage to muddy the water some more? :-)
Joy,
`/anick