On Thu, Jan 30, 2003 at 10:23:14AM -0500, John Baker wrote: > On Thu, 30 Jan 2003, Bob Showalter wrote: > > > If you just want to compare two files to see if one is newer, use the -M > > operator: > > > > $need_recompile = 1 if -M 'foo.java' < -M 'foo.class'; > > > > -M gives you the age in days of a file, measured from the time your script > > was started (stored in the special $^T variable). The specific value > > returned from -M isn't important in this case, but two -M returns can be > > compared to see which file is newer. > > > That's a really elegant solution. I like that. =)
In that case, you'll love this one :-) $need_recompile = -M 'foo.java' < -M 'foo.class'; This has the advantage of always setting $need_recompile to something, rather than relying on the previous value where a compile was not necessary (which was, at least, fail safe). It also has the advantage of allowing you to say my $need_recompile = ... which would have had surprising effects with the initial example, due to the "if". -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
