[Israel.pm] How to open a file on a network drive, using CGI.

Shlomo Yona shlomo at cs.haifa.ac.il
Tue May 4 00:32:33 PDT 2004


On Tue, 4 May 2004, roi sh wrote:

> Actualy it's a directory i'm trying to read.

You might want to use the proper function for readin
directories, e.g., readdir.

Here is the the text 'perldoc -f readdir' outputs for it:

readdir DIRHANDLE
	Returns the next directory entry for a directory opened by
	"opendir".  If used in list context, returns all the rest of
	the entries in the directory.  If there are no more entries,
	returns an undefined value in scalar context or a null list in
	list context.

	If you're planning to filetest the return values out of a
	"readdir", you'd better prepend the directory in question.
	Otherwise, because we didn't "chdir" there, it would have been
	testing the wrong file.

	opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
	@dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR);
	closedir DIR;

-- 
Shlomo Yona
shlomo at cs.haifa.ac.il
http://cs.haifa.ac.il/~shlomo/




More information about the Perl mailing list