Path: utzoo!attcan!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!wuarchive!wuphys!marty From: marty@wuphys.wustl.edu (Marty Olevitch) Newsgroups: comp.lang.perl Subject: Weirdness with <> input operator Message-ID: <1991Feb28.171434.6125@wuphys.wustl.edu> Date: 28 Feb 91 17:14:34 GMT Reply-To: marty@wuphys.UUCP (Marty Olevitch) Organization: Physics Dept, Washington U. in St Louis Lines: 32 Well, now that "Programming Perl" is available, I have learned enough to get quite confused! I've been converting a few of my little C utilities into perl, and ran into this problem. Say I have an array of (open) file handles @handle. Then if I try for($i = 0; $i <= $#handle; $i++) { $line = <$handle[$i]>; } it doesn't put the next line from the file into $line, but rather the name of the file handle (and seems to miss every other one). However, the following: for($i = 0; $i <= $#handle; $i++) { $filehandle = $handle[$i]; $line = <$filehandle>; } does read the next line into $line. Is this the way it is supposed to work? This is using perl 3.0 at patchlevel 44. Also, I found that using the <> operator with an array argument, for example <@foo> , reads the next item in the foo array. But I didn't see this documented in the perl book, at least where the main discussion of the input operator takes place. Going back to the first example, does perl think that $handle[$i] is supposed to be an array? Marty Olevitch Internet: marty@wuphys.wustl.edu Washington University UUCP: uunet!wugate!wuphys!marty Physics Department, Campus Box 1105 Bitnet: marty@wuphys.WUSTL St Louis MO 63130 USA Tel: (314) 889-6285