Path: utzoo!attcan!uunet!know!zaphod.mps.ohio-state.edu!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: A gripe about catching programming errors in Perl Message-ID: <10129@jpl-devvax.JPL.NASA.GOV> Date: 27 Oct 90 06:43:10 GMT References: <8974@cognos.UUCP> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 27 In article <8974@cognos.UUCP> alanm@cognos.UUCP (Alan Myrvold) writes: : Recently, I wrote a bit of a perl script that looked something : like this: : : open(oct,"< October"); : while () { : print; : } : : Even though the file October exists, nothing was printed. This : is due to my choice of oct as a filehandle, since oct is a built-in : function. : : Why couldn't I have at least gotten a warning during the compile? : With perl's big collection of functions, I can't be the only one : making mistakes like this. Is it ever proper to use a function name : where a file handle is expected? Yes, it is. The above converts the octal value found in $_ to a decimal value, then uses that number as the filehandle. Why you'd want to do that is beyond me, but it's perfectly legal--the first argument of open can be any expression yeilding a filehandle. The manual suggests you use upper case for filehandles and labels. There is a REASON for that... Larry