in reply to Remote Module "use"
There was an actual motivation to have - as idsfa remarks - a solution that does not install the module (as Module::AutoINC), but one that only requires limited knowledge and no privileges.
At the institution I work the student
laboratories contain hundreds of computers
that can be started in Linux or Windows. The
OS is replicated from a master copy in a
server.
The administrators are reluctant
to install all the Perl Modules I need
for teaching. The problem is that I keep
discovering interesting new modules and
introducing them in my lectures, which
means I am continuously bothering them,
asking for a new module to be introduced
in the master copy/computer.
However, I can
still install that modules in a machine that
is accesible to the students.
Remote::Use helps to solve these sort of problems. It provides ways to run a Perl program even if some libraries aren't availables at start time. The libraries will be downloaded from a specified server using a specified application that runs on top of some protocol. The clients must be binary compatibles with the server if binary libraries - See Remote::Use::Tutorial for examples - are involved. Typical downloaders are "Rsync" and "Wget" but any suitable alternative like lwp-mirror or "CURL" can be used. This means that many different protocols can be used for the transference: SSH, SFTP, HTTP, HTTPS, FTP, etc. This way, my students can download the modules their programs use to a scratch directory. Once the modules are downloaded they will not be downloaded again, unless the modules are removed from the scratch disk.
Read Remote::Use::Tutorial if you want to know more.
The way to make it work is simple. Consider the following program:
The client machine does not have installed Math::Prime::XS. As the name suggest, the modules involves some binary libraries. By declaring the use of Remote::Use first, the libraries will be downloaded and the program can complete its execution:$ cat -n prime3.pl 1 #!/usr/bin/perl -I../lib -w 2 # The module Math::Prime::XS isn't installed in the machine 3 # but will be downloaded from some remote server 4 use Math::Prime::XS qw{:all}; 5 6 @all_primes = primes(9); 7 print "@all_primes\n"; 8 9 @range_primes = primes(4, 9); 10 print "@range_primes\n";
The libraries are stored in a cache directory. consequently succesive executions don't pay extra overhead:$ time perl -MRemote::Use=config,rsyncconfig prime3.pl receiving file list ... done >f+++++++++ XS.so sent 42 bytes received 16141 bytes 10788.67 bytes/sec total size is 16043 speedup is 0.99 receiving file list ... done >f+++++++++ XS.bs sent 42 bytes received 94 bytes 90.67 bytes/sec total size is 0 speedup is 0.00 receiving file list ... done >f+++++++++ XS.pm sent 42 bytes received 5733 bytes 11550.00 bytes/sec total size is 5635 speedup is 0.98 2 3 5 7 5 7 real 0m2.349s user 0m0.116s sys 0m0.060s
The programmer has however to set a configuration file rsyncconfig setting the parameters that govern the downloading process:$ time perl -MRemote::Use=config,rsyncconfig prime3.pl 2 3 5 7 5 7 real 0m0.066s user 0m0.056s sys 0m0.008s
$ cat rsyncconfig package rsyncconfig; sub getarg { my ($class, $self) = @_; return ( host => 'orion:', prefix => '/tmp/perl5lib/', command => 'rsync -i -vaue ssh', ppmdf => '/tmp/perl5lib/.orion.installed.modules', ); } 1;
Casiano
|
|---|