Eric on 22 Apr 2006 03:19:57 -0000


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

Re: [PLUG] Perl question



On Friday 21 April 2006 8:29 pm, Stephen Gran wrote:
> 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'.

In this case, I have a series of image files are received once a 
day.  If it's a new image (but uses the same name as an existing
file) then it will be created more recently than the thumbnail 
image I create when I first got the original file.

> > 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!  |
> |  steve@lobefin.net             | POP UP, PUSH DOWN, BYTE, BYTE, BYTE!    |
> |  http://www.lobefin.net/~steve |                                         |
>  --------------------------------------------------------------------------

Ctime did it for me.  
Thanks,
Eric 

-- 
------------------------------------------------------------------------
#  Eric A Lucas
#  ------------
#   "Oh, I have slipped the surly bond of earth
#    and danced the skies on laughter-silvered wings... 
#        -- John Gillespie Magee Jr.
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug