☼ 林永忠 ☼ > Tie-RemoteVar-0.02 > Tie::RemoteVar

Download:
Tie-RemoteVar-0.02.tar.gz

Dependencies

Annotate this POD

Related Modules

Tie::Watch
more...
By perlmonks.org

CPAN RT

Open  0
Report a bug
Module Version: 0.02   Source  

NAME ^

Tie::RemoteVar - Share variables everywhere

SYNOPSIS ^

  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;

DESCRIPTION ^

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.

  [$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.

CAVEATS ^

TO DO ^

Recursive copy of Perl datatypes.

COPYRIGHT ^

xern <xern@cpan.org>

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.