Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Are only simple scalars allowed in "do SUBROUTINE (LIST)" ? Message-ID: <7294@jpl-devvax.JPL.NASA.GOV> Date: 6 Mar 90 20:14:19 GMT References: <1211@frankland-river.aaii.oz.au> <7269@jpl-devvax.JPL.NASA.GOV> <21611@watdragon.waterloo.edu> <1990Mar6.180823.27618@iwarp.intel.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 36 In article <1990Mar6.180823.27618@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes: : In article <21611@watdragon.waterloo.edu>, ccplumb@lion (Colin Plumb) writes: : | Well, when I wanted the time from a file, the first thing I tried was : | : | $time = stat($file)[8]; : | : | It didn't work so well. : : I've stumbled across wanting such a syntax as well. I think it's the : C programmer in me that would think it natural. I've held off asking : for it because I'm afraid it would break something. Maybe in Perl 4? :-) It wouldn't be too hard except that EXPR [ EXPR ] successfully parses $var[$foo], and it would be wrong. It could probably be worked out with some more shift-reduce ambiguities, but I'm loath. Would you settle for this? ( LIST ) [ EXPR ] Since LISTs can contain anything that returns array values, you could say $time = (stat($file))[8]; That could be parsed unambiguously, methinks. It would in fact be a slice operator, so you could say @days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat')[$beg .. $end]; What think? Larry