【问题标题】:Perl syntax error when opening a file打开文件时出现 Perl 语法错误
【发布时间】:2014-05-24 04:45:55
【问题描述】:

我编写了一个子例程,当我运行我的程序时,我收到错误消息:“第 74 行的语法错误,靠近‘打开’” 错误是否可能是因为我使用了 my 来声明内容数组?

my @content = do{
        local $/ = \$width;
        <$fh>;
    }



    open(OUT, ">", $outfile) or die "cannot open \n"; #this is line 74
    binmode(OUT);
    foreach ( @content ){
        print OUT $_;
    }

    close(OUT);

【问题讨论】:

    标签: perl variables syntax scope


    【解决方案1】:

    你之前的行中缺少分号,

    my @content = do{
        local $/ = \$width;
        <$fh>;
    }; # semicolon
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 2019-05-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多