[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] MAC Filesystem Help



>On the MAC I have a folder on the Desktop called "Frads" and this folder 
>contains many (probably about 50) files. I want to open each file 1 by
>1 (using a while statement as above) and then operate on the file. I guess the
>main help I need is figuring out how to access the MAC file system so 
>I can open each file in the "Frads" folder 1 by 1. I think this should be very
>easy for anyone who has experience using MAC-perl.

After knowing the manner how to describe file path, and correcting
your script so as to work on MacPerl, you can get good results.

Assuming the followings:

	Disk Name:	'MyDisk'
	Folder Name:	'SomeFolder'
	File Name:	'hoge'

Write as followings:

	Absolute path:
		"MyDisk:SomeFolder:hoge"

	Relative to current folder (relative to MacPerl folder
	or the forder where your script is placed):

		"hoge"

		or

		":hoge"

	Relative to current folder but in sub-folder:

		":SomeFolder:hoge"

	Relative to current folder but in upper-folder:

		"::hoge"

	Relative to current folder but in sub-folder of upper-folder:

		"::SomeFolder:hoge"

Summary:

				UNIX		Macintosh
	---------------------------------------------------------
	current directory	./		:
	upper directory		../		::
	root directory		/		(Disk Name)
	file in CWD		(Some Name)	(Some Name)
	directory/folder in CWD	(Some Name)	":" + (Some Name)
	
	In Macintosh, file name alone, or starting ":" and ending
	other character than ":" means the file or folder in current 
	working directory/folder.

	If the last character of the name/path is equal to ":",
	Macintosh think it is folder/directory.

	If the first character of the name/path is not ":" but 
	the name/path contains ":", Macintosh think it is absolute path.

Can you understand?

If you wish to make it more easily, you should better to use
"&MacPerl'Choose" function.  Try as follows:

	require "GUSI.ph";
	
	exit unless ($dir = &MacPerl'Choose(&GUSI'AF_FILE, 0,
				"Which folder", "",  &GUSI'CHOOSE_DIR));

	opendir(TEMP, $dir);
	
	foreach $file (readdir(TEMP)) {

		$fname = "$dir:$file";

		next if (-d $fname); # skip sub-folder
				     # you must also skip invisible file

		print "$fname\n";    # replace this line by your work;

	}

	closedir(TEMP);

Once you run above script, you can understand how it work, I think.

-------------------------------------------------
Mamoru Yamanishi <yama@biotech.okayama-u.ac.jp>
+81-86-251-8196(voice), +81-86-251-8264(GIII fax)
Biotech. Dept., Okayama Univ.



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch