我有一個哈希數組要返回。Perl - 返回哈希數組
在返回數組之前我交叉檢查它。它工作正常。
但在hashess數組返回給調用子之後,我無法讀取它。
PLZ找到referrence下面的代碼..而且不要讓我知道如何讀/返回哈希
由於數組... :)
#!/usr/bin/perl
use strict;
use warnings;
# Subroutine prototypes
sub get_two_arrays();
my @one=();
@one = get_array_Hashes();
print "\n First: @one->{Version}\n"; // Printing the return array of hashes
sub get_array_Hashes() {
my @dotNetHashArray =();
my $dotNetHash1 = {Version => "Test-1 Version", SP => "installedSp", Build => "installedBuild"};
push @dotNetHashArray, $dotNetHash1;
my $dotNetHash2 = {Version => "Test-2 Version", SP => "installedSp", Build => "installedBuild"};
push @dotNetHashArray, $dotNetHash2;
my $dotNetHash3 = {Version => "Test-3 Version", SP => "installedSp", Build => "installedBuild"};
push @dotNetHashArray, $dotNetHash3;
print "Test Array of hashes before return";
for(my $i=0; $i<@dotNetHashArray; $i++)
{
print("\n Hash Value : ".$dotNetHashArray[$i]->{Version});
}
return \@dotNetHashArray
}
您返回對數組的引用,而不是數組。 –
然後你的打印值的方式也不起作用,你在某處省略了一個循環。 –
側面。如果你是5.10或更高版本,我寧願打印「\ n」,特別是如果\ n在行首 – justintime