1

これは私の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 を使用して、PC のローカル ホストでスクリプトを実行しています。

プログラムでファイル内のすべての行を印刷したいだけです。

ブラウザでは次のように表示されます。

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.
4

1 に答える 1