perl - 跨 Perl 脚本共享哈希

标签 perl hash sharing

是否可以在 Linux 机器上共享由另一个 Perl 脚本创建的哈希值?

./hash_script.pl # Creates a hash after parsing a file
                 # Takes several minutes and hash consumes 4Gb of memory

./script1.pl # Reads hash

./script2.pl # Reads hash

我想创建一次哈希并多次使用它,无论何时运行 script1.plscript2.pl

最佳答案

如果您的 hash_script 脚本将其散列转储到某个文件中(使用 Data::Dumper 或其他方式),您可以使用 do 在后续脚本中加载该散列。

在脚本 1/脚本 2 中:

our %sharedhash; #whatever name the hash has in the dumped file
do 'hash_dump_file.txt' or die "Couldn't read hash: $@";

print $sharedhash{stuff};

关于perl - 跨 Perl 脚本共享哈希,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20080989/

相关文章:

c++ - 用于签署散列和验证散列签名的 MSDN C 示例程序不起作用

c# 在 chrome 中使用哈希 (#) 打开 url

php - 使用php : Password hash doesn't match批量创建seafile用户(cloudstorage)

c# - 从 Windows Phone 8 共享

Hadoop 计算所有拆分中所需的术语

perl - Perl 子例程从哪里获取实际参数中缺少的值?

perl - 如何加载相对于模块路径的文件?

android - 在对象之间共享实例的最佳实践

perl - 将字符串 "0x30"和十六进制数 0x30 传递给 hex() 函数之间的区别

linux - 如何编写脚本以使用我的凭据连接到 ssh 服务器?