Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Novice surprise Message-ID: <11393@jpl-devvax.JPL.NASA.GOV> Date: 12 Feb 91 00:13:22 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 33 In article bobg+@andrew.cmu.edu (Robert Steven Glickstein) writes: : It was two hours of staring at this stupid thing before I realized : that the problem was this: The filenames that I was passing as : arguments happened to begin with a "+". Since I didn't have : write-access, I got a "cannot open file" error. I couldn't figure out : a way to circumvent this in Perl, so instead of the command-line : : perlscript +a +b +c : : I used : : perlscript ./+a ./+b ./+c : : The big question: What is the *right* way around this problem? Er, don't use a toy language for a real problem... :-) I think that most people avoid the problem by not using filenames beginning with + or >. If you really want to write a bulletproof script, you might put the following before the initial loop: for (@ARGV) { s#^([^/])#./$1#; s#$#\0#; } while (<>) {... In general, filenames starting with + aren't quite as dangerous as those starting with -, but there are some programs that use + to introduce switches, so it's probably a bad idea. You can't, for example, say sort +a +b +c Just don't create a file called -rf. :-) Larry