无法打印数组引用perl

时间:2017-09-15 18:40:59

标签: arrays perl pass-by-reference

我在第一个函数中打印出数组,它是有效的。我无法在第二个功能中将其打印出来。

错误消息:不能使用字符串(" 1")作为ARRAY参考,而#34; strict refs"在ConvertToVformat.pl第24行使用。

my $dir = cwd();
my $source_files = DetermineSourceFiles();
DetermineFileInfo($source_files);

sub DetermineSourceFiles {
    my @source_files;
    opendir my $dh, $dir or die "Cant open $dir: $!";
    while (my $file = readdir($dh)) {
        if ($file =~ /(.*?\d+.bin)/) {
            push @source_files, $file;
        }
    }
    closedir $dh;
    return \@source_files;
}

sub DetermineFileInfo {
    my $source_files = (@_);
    foreach my $file (@$source_files) {
        print "$source_files\n";
    }
}

1 个答案:

答案 0 :(得分:0)

使用

.vote

而不是

$(document).on('click', ".vote", function(e){
    href = $(this).attr("href");
    postId = $(this).attr("postId");
    $.ajax({
       url: href,
       success: function() {
          $("#post-"+postId+" >header").load(location.href+ " #post-"+postId+">header>*");
       },
   });
})

有关详细信息,请参阅documentation of shift