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