gpt4 book ai didi

perl - Perl语法错误: Sample Program to read a file

转载 作者:行者123 更新时间:2023-12-03 08:13:52 25 4
gpt4 key购买 nike

读取文件时出现错误,下面是脚本。

#!/bin/bash
$file = "SampleLogFile.txt"; #--- line 2
open(MYINPUTFILE,$file); #--- line 3
while(<**MYINPUTFILE**>) {

# Good practice to store $_ value because
# subsequent operations may change it.
my($line) = $_;

# Good practice to always strip the trailing
# newline from the line.
chomp($line);

# Convert the line to upper case.
print "$line" if $line = ~ /sent/;

}
close (MYINPUTFILE);

输出:

PerlTesting_New.ksh [2]:=:找不到
PerlTesting_New.ksh [3]:第3行出现语法错误:`('意外

知道是什么问题吗?

最佳答案

更改

#!/bin/bash


#!/usr/bin/perl

否则,Perl将不会解释您的脚本。根据您的系统相应地更改路径

关于perl - Perl语法错误: Sample Program to read a file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8037218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com