讀取文件時出現錯誤,下面是腳本。Perl語法錯誤:讀取文件的示例程序
#!/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行語法錯誤:`(」意外
不限知道是什麼的問題是什麼?
'!#/ usr/bin/env perl'的解釋器行對於找到可以在PATH中找到的Perl很有用。 – JRFerguson
我是一個新手,儘管我按照 – crackerplace
更改了相同的錯誤你是如何調用腳本的? – choroba