Gene Ray wrote:

> Hello all.
> 
> I have a script in a directory called "banners"
> I'm trying to read the contents of the directory with a script I
> pulled from a book.
> I keep getting the sub ErrorMessage text and don't understand why.
> Isn't the "." supposed to be for the working directory? ie where the
> script resides?
> 
> opendir (LOGDIR,".") || &ErrorMessage;
> @logfiles = readdir (LOGDIR);
> closedir (LOGDIR);
> if (@logfiles) {
> print "<p>You can choose from the following logs:";
> foreach $filename (@logfiles) {
> print "<LI>$filename" unless
> ($filename =~ /^\.+$/);
> }
> }
> sub ErrorMessage {print "sorry no such directory"}

Typically . would be the directory that you called the script from on the 
command line (in unix/linux) not necessarily where the script itself 
resides. i.e. if the script is in /home/webdragon/bin (which ~/bin being in 
my $PATH) and I am currently in /home/webdragon/public_html/images, then 
the script will see that last as . if I call it from there, NOT 
/home/webdragon/bin/.

For proper cross-platform conversion of directory paths, you'd most likely 
wish to use the File::Spec module from CPAN. 

In Classic MacOS, the directory : is the current working dir. :: is the 
directory above that. Volumename:: would be the top level dir (for that 
volume/drive) .. this is unlike unix, where / is ALWAYS the top level dir, 
no matter which volumes are mounted. 

This makes for some minor confusions when working between MacOS and some 
form of unix/linux. 

File::Spec is one way to (somewhat) work around these differences, but you 
DO need to be aware of just how differently Classic MacOS looks at 
directories and volumes, as opposed to the unix way of doing things. 


Reply via email to