in reply to extracting year of a file

You can use stat and POSIX::strftime() to extract the mtime year. I think mtime is the proper concept, since in a way it is when the file was created in its current form.

Here's a small demo:

$ cat >foo.txt [Ctrl-D] $ perl -MPOSIX=strftime -e'print strftime("%Y\n", > localtime((stat "foo.txt")[9]))' 2007 $
That gives you the year as a string, but you can add zero to that if you want it taken as a number.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: extracting year of a file
by graff (Chancellor) on Feb 03, 2007 at 17:23 UTC
    And since the POSIX module exports its functions by default, you can just say:
    $ perl -MPOSIX -e'...'
    (or just  use POSIX; in a longer perl script).