这是对我的旧问题的扩展:使用 system 将哈希对象从一个 perl 脚本传递到另一个。@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";
我怎样才能做到这一点?任何帮助将非常感激。
谢谢!