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

Re: [MacPerl] open() misfeature?



Matthias Ulrich Neeracher <neeri@iis.ee.ethz.ch> writes:
}h0444zkf@rz.hu-berlin.de (Erich Rast) writes:
}>First of all: forget about the script I've recently put on this list. It's
}>full of horrible bugs and won't work (by the way, it's now called
}>'httpjob.pl' ;-)
}
}BTW, Perl scripts should not have a .pl suffix. Only perl4 library files
}should
}be written with a .pl suffix.

I always use .pl for my top level scripts, and .pm for any files that need
to be "use"d.

}
}># Can't open ' Mac:Desktop Folder:index.html': Invalid argument
}>              ^
}>              |
}>               - that's the problem!
}
}Yes, open() is documented to ignore leading & trailing spaces. IO::File should
}be able to open spaced out files.

The IO::File that's distributed with MacPerl says:

	if ($^O eq 'MacOS') {
            $file = ":" . $file unless $file =~ m#^/#;

which protects whitespace, but will wreak havok with $file = ":file".  I've
got a fixed version at

<ftp://mors.gsfc.nasa.gov/pub/MacPerl/Scripts/Fixed_Library_Routines/IO/File.pm>

which protects whitespace

	if ($^O eq 'MacOS') {
            $file = ":" . $file unless $file =~ m#^\S#;


but obviously only on relative paths.  Offhand I can't think of a good way
to protect whitespace on a top volume name; this trick won't work.

}
}Matthias
}
}-----
}Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
}  "And that's why I am going to turn this world upside down, and make
}   of it a fire so *bright* that someone real will notice"
}                                -- Vernor Vinge, _Tatja Grimm's World_


---
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693, Greenbelt, MD 20771
schinder@pjstoaster.pg.md.us