Path: utzoo!attcan!uunet!samsung!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Perl "do" bug. Message-ID: <7026@jpl-devvax.JPL.NASA.GOV> Date: 8 Feb 90 19:43:16 GMT References: <1990Feb7.190655.16030@eci386.uucp> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 35 In article <1990Feb7.190655.16030@eci386.uucp> clewis@eci386 (Chris Lewis) writes: : When you : : do 'something'; : : And "something" isn't in your home directory (though it's directory is in : @INC), $! is set to "No such file or directory". Even though perl actually : did read the file, $@ is zero/null and definitions set therein can be : referenced. Sometimes this appears to depend on the contents of the : perl script, but I've not narrowed it down very far. Both Perl 2 and 3. : : I suspect that this is actually errno being set on the first open attempt : (in your home directory), but isn't being reset on a later successful : open. I think your analysis is correct. I don't think you should rely on the value of $! at that point though. The fact that $@ is null means there was no compilation error. To indicate successful execution of 'something' I've been putting a 1; at the end of every 'something' I write. The you can just say do 'something' || die "Couldn't do something"; To specifically check for whether the file was found you could say $foo = do 'something'; die "Couldn't find something" unless defined $foo; die "Couldn't parse something: $@" if $@; die "Couldn't run something" unless $foo; $! is not meant to be anything more than what errno is. And errno just reflects the last error on a system call. Something as complicated as a path search does a number of system calls. Larry