Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!umich!samsung!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: $! and string context Message-ID: <8730@jpl-devvax.JPL.NASA.GOV> Date: 15 Jul 90 05:32:06 GMT References: <1990Jul13.175014.1750@uvaarpa.Virginia.EDU> <15668@bfmny0.BFM.COM> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 18 In article <15668@bfmny0.BFM.COM> tneff@bfmny0.BFM.COM (Tom Neff) writes: : In article <1990Jul13.175014.1750@uvaarpa.Virginia.EDU> worley@compass.com writes: : >People might be interested to note that the conditional expression in : >an 'if' is a string context, which I didn't expect. The : >string/numeric context difference seems to usually be unimportant, but : >$! is an exception: : > : > die "Can't do ..." if $!; : : Try using the standard workaround for this sort of thing: : : dir "Can't do ..." if 0+$!; That's fine as a workaround. However, I'll make it so that if errno is 0, it returns the null string in a string context. Then the boolean value will be unsurprising. Larry