in reply to Auto install of a perl package if 'use' statement fails
Yes. I've seen it done. I believe that Abigail did it, but I can't find the code.
Anyways the idea is simple. If you read the documentation for require, you'll find that you can put subroutines in @INC. Then you can pull tricks like this untested code:
(This one grabs the module off of a webserver, and loads it directly. No local installation needed! With older versions of Perl you'll need IO::Scalar instead of the open trick that I used to put the contents of a scalar into a filehandle.)use LWP::Simple qw(get); BEGIN { push @INC, sub { shift; my $file = shift; # eg "Foo/Bar.pm" my $content = get("http://myrepository.com/modules/$file"); if ($content) { open(my $fh, "<", \$content); return $fh; } else { return; } } }
In Section
Seekers of Perl Wisdom