Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: sort Message-ID: <105837@convex.convex.com> Date: 5 Sep 90 21:36:06 GMT References: <9337@jpl-devvax.JPL.NASA.GOV> <9384@jpl-devvax.JPL.NASA.GOV> Sender: usenet@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 45 In article <9384@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: >Other items sneaking in at the last moment. Filetests -M, -A and -C will >return the file's age in days (possibly fractional) at the time the script >started. This will make it much easier to write middle-of-the-night >skulkers. The "at the time of the script" part bothers me a bit; I'd MUCH rather it were their "instantaneous" age. When I first saw those operators, I expected them to return a time I could pass to &ctime(), but instead they give me age. If I want the real time, I guess I could use (stat(FILE))[9] for mtime and so on. Certainly these could be easily implemented as subroutines; I'd venture to guess, Larry, that you consider them common enough operations to make them builtins. Speaking of such things, I've found myself writing code like this: if ((stat($tmp))[9] <= (stat($orig))[9]) { And wishing I could use something like this instead if ($tmp -nt $orig) where "-nt" is a binary operator that returns whether the first operand (either a FILE or a $file) is younger than the second. The Korn shell has these three interesting built-in tests: file1 -nt file2 True if file1 exists and is newer than file2. file1 -ot file2 True if file1 exists and is older than file2. file1 -ef file2 True if file1 and file2 exist and refer to the same file. I would guess the first two compare mtimes and the last one compares (dev,ino) pairs. At least the first two seem common enough to be operators. --tom -- "UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever things." [Doug Gwyn]