GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
IPC::PerlSSH::Library(3) User Contributed Perl Documentation IPC::PerlSSH::Library(3)

"IPC::PerlSSH::Library" - support package for declaring libraries of remote functions

 package IPC::PerlSSH::Library::Info;

 use strict;
 use IPC::PerlSSH::Library;

 func uname   => 'uname()';
 func ostype  => '$^O';
 func perlbin => '$^X';

 1;

This can be loaded by

 use IPC::PerlSSH;

 my $ips = IPC::PerlSSH->new( Host => "over.there" );

 $ips->use_library( "Info" );

 print "Remote perl is running from " . $ips->call("perlbin") . "\n";
 print " Running on a machine of type " . $ips->call("ostype") .
                                          $ips->call("uname") . "\n";

This module allows the creation of pre-prepared libraries of functions which may be loaded into a remote perl running via "IPC::PerlSSH".

All the code is kept in its own package in the remote perl. The package declaration is performed in the remote perl, by including an optional block of initialisation code, passed to the "init()" function.

Typically this code could "use" a perl module, or declare shared variables or functions. Be careful when "use"ing a module, as the remote perl executing it may not have the same modules installed as the local machine, or even be of the same version.

Note that "our" variables will be available for use in stored code, but limitations of the way perl's lexical scopes work mean that "my" variables will not. On versions of perl before 5.10, the variable will have to be "our"ed again in each block of code that requires it. On 5.10 and above, this is not necessary; but beware that the code will not work on remote perls before this version, even if the local perl is 5.10.

For example, consider the following small example:

 package IPC::PerlSSH::Library::Storage;

 use IPC::PerlSSH::Library;

 init q{
    our %storage;

    sub list  { keys %storage }
    sub clear { undef %storage }
 };

 func get   => q{ our %storage; return $storage{$_[0]} };
 func set   => q{ our %storage; $storage{$_[0]} = $_[1] };
 func clear => q{ clear() }
 func list  => q{ return list() }

 1;

   func( $name, $code )

Declare a function called $name, which is implemented using the source code in $code. Note that $code must be a plain string, NOT a CODE reference.

The function name may not begin with an underscore.

Declare library initialisation code. This code will be executed in the remote perl before any functions are compiled.

Paul Evans <leonerd@leonerd.org.uk>
2022-04-09 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.