这是我的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.