use strict;
use Win32::MMF::Shareable;
use Data::Dumper;
my $ns = tie my $ref, 'Win32::MMF::Shareable', '$ref';
tie my $alias, 'Win32::MMF::Shareable', '$ref';
$ref = { a => 1, b => 2, c => 3 };
$alias->{d} = 4;
print Dumper($ref);
$ref = [ qw( a b c d e f g h ) ];
print Dumper($alias);
# $ns->debug();
####
__OUTPUT__
$VAR1 = {
'c' => '3',
'a' => '1',
'b' => '2',
'd' => 4
};
$VAR1 = [
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h'
];
##
##
+-----------------+
| Var1 definition |
+-----------------+
| Var2 definition |
+-----------------+<- Heap Top
| |
| |
| |
| |
| |
| |
| |
| |
|-----------------|<- Watermark
| |
| |
| |
| |
+-----------------+<- Heap Bottom
| MMF Descriptor |
+-----------------+
##
##
use strict;
# ----------------------------------------------------------------
# code to switch between Win32::MMF::Shareable and IPC::Shareable
# automatically on different platforms
# ----------------------------------------------------------------
use vars qw/ $Shareable /;
BEGIN {
$Shareable = ($^O eq 'MSWin32') ? 'Win32::MMF::Shareable'
: 'IPC::Shareable';
eval "require $Shareable";
$Shareable->import();
}
# ----------------------------------------------------------------
my $glue = 'data';
my %options = (
create => 0,
exclusive => 0,
mode => 0644,
destroy => 0,
);
my %colours;
tie %colours, $Shareable, $glue, { %options } or
die "client: tie failed\n";
foreach my $c (keys %colours) {
print "client: these are $c: ",
join(', ', @{$colours{$c}}), "\n";
}
delete $colours{'red'};
exit;