문제

I'm using TextWrangler on a Mac to run Perl.

I have a text file that I want to open as an input file to TextWrangler, but I keep getting the error message, Error: cannot open file simap data.txt for reading.

I know my code is correct because it worked on a PC (using Perl Express).

However I don't think I've saved the text file I'm trying to open in the right place. Where should I save it?

도움이 되었습니까?

해결책

Unless you provide a full path to the file, your program will look for it in the current working directory. You can put the file anywhere you like if you write the open call as

open my $fh, '<', '/full/path/to/simap data.text' or die $!;

Or if you want to omit the path and put it in the current working directory, and you don't know where that is, then add

use Cwd 'abs_path';
print abs_path('simap data.text'), "\n";

and you will see where the program will look if you provide just a filename to the open.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top