这是我的 Apache 错误日志:
[Fri Nov 15 08:55:41.771706 2013] [cgi:error] [pid 4292:tid 1500] [client ::1:35659] AH01215: [Fri Nov 15 08:55:41 2013] testaccounts.pl: Could not open accounts.txt: No such file or directory at C:/wamp/www/testaccounts.pl line 42., referer: http://localhost/testaccounts.pl
我正在尝试从与我的脚本位于同一目录中的文件中读取。我正在使用 wamp 并在我的电脑上的本地主机上运行脚本。
我只想让我的程序打印文件中的每一行。
在浏览器上它说:
Software error:
Could not open accounts.txt: No such file or directory at C:/wamp/www/testaccounts.pl line 42.
这是我的程序导致错误的部分:
elsif (param('username') and param('password')) #if a user-name and password is typed in
{
$username=(param('username'));
$password=(param('password'));
$title = 'Account: ' . $username;
my $file = 'accounts.txt';
open $file or die "Could not open $file: $!";
while( my $line = <$file>) {
print $line;
}
我也试过:
my $file = '/accounts.txt';
$file = $dir . $file;
这给了我:
Could not open C:/wamp/www/accounts.txt: No such file or directory at C:/wamp/www/testaccounts.pl line 45.