1
阅读这是我的Apache的错误日志:的Perl CGI从txt文件
[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.
这是我的计划cauing错误的部分:
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;
哪给出me:
Could not open C:/wamp/www/accounts.txt: No such file or directory at C:/wamp/www/testaccounts.pl line 45.
我已经尝试了你说的并更新了我的答案。你能进一步解释吗?谢谢 – user2995563