Stephen Gran on 22 Apr 2006 00:29:46 -0000

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Perl question

On Fri, Apr 21, 2006 at 07:31:58PM -0400, Eric said:
> In the shell I can easily compare the dates of two files:
> $  if [ .y2log -nt .y2log-1 ]; then
>      echo .y2log is newer than .ylog-1
>    else
>      echo .y2log is older than .ylog-1
>    fi
> .y2log is newer than .ylog-1
> $
> So what is the similar perl idiom for comparing file dates?

It depends on what you mean by 'newer'.

> I have to compare 166,000 (+) pairs of files and I'd rather
> do it with perl.  Particularly since I open the directory
> and read the filenames into a hash which turns out to be
> wicked-fast for processing the file names.

perldoc -f stat is your friend here.  There are several ways of
determining newer (test uses mtime, but that's not the only measure), so
you'll need to work out what you want to test for.
|  Stephen Gran                  | SHIFT TO THE LEFT! SHIFT TO THE RIGHT!  |
|             | POP UP, PUSH DOWN, BYTE, BYTE, BYTE!    |
| |                                         |

Attachment: signature.asc
Description: Digital signature

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --