Perl 中hash_ref 传递问题,从一个程序传到另一个perl程序的问题

2025-05-02 00:27:37
推荐回答(1个)
回答1:

既然能传数组,又何苦强迫症呢……

test.pl:

use strict;

use warnings;

use Data::Dumper;


my $hash_ref = {

'4' => 'd',

'1' => 'a',

'3' => 'c', 

'2' => 'b',

};


print "here is test.pl...\n";

print Dumper($hash_ref);

my @array = %$hash_ref;

my $args = join " ", @array;

print $args . "\n";

my $cmd = "perl try.pl $args";

system ("$cmd")


try.pl:

use strict;

use warnings;

use Data::Dumper;


my %rec = @ARGV;


print "\n\nhere is try.pl...\n";

print Dumper (\%rec);