【发布时间】:2015-10-13 13:56:09
【问题描述】:
这是对我以前的问题的扩展:Pass a hash object from one perl script to another using system。 @Sobrique 在那里回答了我的问题。
现在,我想知道是否可以以与我上面的问题相同的方式将哈希对象传递给另一个 perl 脚本,但使用 bsub。
包装脚本:script1.pl
use strict;
use warnings;
use Storable qw ( freeze );
use MIME::Base64;
my %test_hash = (
"fish" => "paste",
"apples" => "pears"
);
my $frozen = encode_base64 freeze( \%test_hash );
my ${string} = 'sample1';
# instead of just using system like this
# system("perl", "some_other_script.pl", $frozen);
# I want to use something like this:
system('bsub','-J',${string},'-o','${string}.out','-e','${string}.err','perl','some_other_script.pl',$frozen);
some_other_script.pl
use strict;
use warnings;
use Storable qw ( thaw );
use Data::Dumper;
use MIME::Base64;
# should read the imported hash correctly and print it out
my ($imported_scalar) = @ARGV;
print $imported_scalar;
my %param = %{ thaw (decode_base64 $imported_scalar ) };
print $param{'fish'};
print "\n";
我怎样才能做到这一点?任何帮助将不胜感激。
谢谢!
【问题讨论】:
-
你试过这个方法有用吗?你得到了什么错误?
-
没有返回哈希值,只是对哈希值的引用。
-
我查看了 .out 文件,上面写着:
# LSBATCH: User input perl some_other_script.pl BAcIMTIzNDU2NzgECAgIAwIAAAAKBXBlYXJzBgAAAGFwcGxlcwoFcGFzdGUEAAAAZmlzaA==