Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.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: ignore write(HANDLE); Keywords: perl write Message-ID: <9609@jpl-devvax.JPL.NASA.GOV> Date: 21 Sep 90 19:09:53 GMT References: <261@carssdf.UUCP> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 25 In article <261@carssdf.UUCP> usenet@carssdf.UUCP (John Watson) writes: : I seem to be having a problem with even the simplest scripts that use : the write stmt. I do something like: : open(HNDL); $^ = 'TOP'; $~ = 'FMT'; write(HNDL); etc... : and it does not write! (except sometimes), then later on in the same : program it will work. Once it starts working, it seems to be ok. Writing : to stdout works more ofter it think. That's because you're setting $^ and $~ for STDOUT, not HNDL. Say open(HNDL) || die; local($oldhndl) = select(HNDL); $^ = 'TOP'; $~ = 'FMT'; select($oldhndl); ... write(HNDL); or the way Randal will suggest: open(HNDL) || die; select((select(HNDL), $^ = 'TOP', $~ = 'FMT')[0]); ... write(HNDL); Larry