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


Manual Reference Pages  -  IPC::PERLSSH::LIBRARY (3)

.ds Aq ’

NAME

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

CONTENTS

SYNOPSIS



 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->load_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";



DESCRIPTION

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 useing 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 oured 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;



FUNCTIONS

func( CW$name, CW$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.

init( CW$code )

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

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 IPC::PERLSSH::LIBRARY (3) 2016-03-17

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