Tie::RemoteVar - Share variables everywhere
use Tie::RemoteVar; # server side my $vs = Tie::RemoteVar->new(allow => '127.0.0.1'); $vs->startserver; # client side tie(%HASH, 'Tie::RemoteVar', id => 'meatball'); untie %HASH;
Users can treat inter-process or even inter-host variables almost as normal ones using Tie::RemoteVar instead of stereotypical tedious coding.
To use this facility, users need to setup a server first. It is simple. The only requirements are allowed hosts' addresses and server's port.
Localhost access is not presumed valid before users make an explicit statement.
my $vs = Tie::RemoteVar->new( port => 1234 # default is 1234 allow => [ '127.0.0.1', '140.112..+' ], );
then start it
$vs->startserver;
After setup is completed, users are empowered to access variables across processes or hosts. Likewise, default port is 1234 and default host is 127.0.0.1. Additionally, users need to specify the variable's identifier on server, which is similar to the key used in shmget. It is required in order to locate variable after program's termination.
key
shmget
[$x =] tie(%HASH, 'Tie::RemoteVar', id => 'meatball'); [$x =] tie(@ARRAY, 'Tie::RemoteVar', addr => '127.0.0.1', port => 1234, id => 'spaghetti'); [$x =] tie($SCALAR, 'Tie::RemoteVar', port => 1234, id => 'YangZhou ChaoFan'); untie $SCALAR; untie @ARRAY; untie %HASH;
Since variables must be preserved after termination of scripts, users cannot use untie or undef to destroy variables. Instead, Tie::RemoteVar provides erase to perform this task.
$x->erase();
It will erase the variable stored on the server.
Tie-filehandle is not supported.
Cannot handle variables of complex structure.
Recursive copy of Perl datatypes.
xern <xern@cpan.org>
This module is free software; you can redistribute it or modify it under the same terms as Perl itself.
To install Tie::RemoteVar, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::RemoteVar
CPAN shell
perl -MCPAN -e shell install Tie::RemoteVar
For more information on module installation, please visit the detailed CPAN module installation guide.