我的Perl项目可以在多个系统上运行,但我不希望它们在不知道其他系统正在做什么的情况下单独运行.我需要保持他们的数据文件或多或少同步,这意味着合并他们的内容,所以我需要一个数据结构来包含每台计算机的详细信息以及对另一台计算机的引用.
正是这种引用导致了我的问题.
如果我将它简化为两台PC
use strict;
use warnings;
use Sys::Hostname;
# Peer computers
my $PC1 = {
name => 'PC1',
os => 'Linux',
data => '/its/data/directory',
peer => 'PC2' # But whas is really needed here is a reference to PC2's data structure below
};
my $PC2 = {
name => 'PC2',
os => 'MSWin32',
data => 'X:\\its\\data\\directory',
peer => 'PC1' # But whas is really needed here is a reference to PC1's data structure above
};
my $PEERS = [ …Run Code Online (Sandbox Code Playgroud)