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

Re: [Omaha.pm] Less is more



Not sure why Date::Format might be different, but the POSIX version worked for me:

use POSIX qw(strftime);
($month,$day,$year) = split(/\//,strftime("%D",localtime((stat($file))[9])));

-Andy

-----Original Message-----
From: Ryan Stille [mailto:rps@willcomminc.com]
Sent: Thursday, December 22, 2005 11:51 AM
To: Perl Mongers of Omaha, Nebraska USA
Subject: [Omaha.pm] Less is more


I am was trying to get this done in one line, just for the heck of it.
I need the modification time of a file referenced by $file ($file
contains the path and filename of the file).

@filedate = localtime((stat($file))[9]);
($month,$day,$year) = split(/\//,strftime("%D",@filedate));

But I can't seem to put localtime in place of @filedate:

($month,$day,$year) =
split(/\//,strftime("%D",localtime((stat($file))[9])));

Gives me: Type of arg 2 to Date::Format::strftime must be array (not
localtime)

So I tried to make localtime() return as an array, and here is where I'm
not so sure as to what I'm doing.

I tried this:

($month,$day,$year) =
split(/\//,strftime("%D",(localtime((stat($file))[9]))));

And this:

($month,$day,$year) =
split(/\//,strftime("%D",(localtime((stat($file))[9]))[]));

Which didn't work either.  What am I doing wrong?

Thanks,
-Ryan

_______________________________________________
Omaha-pm mailing list
Omaha-pm@pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
******************************************************************************************
The information contained in this message, including attachments, may contain 
privileged or confidential information that is intended to be delivered only to the 
person identified above. If you are not the intended recipient, or the person 
responsible for delivering this message to the intended recipient, ALLTEL requests 
that you immediately notify the sender and asks that you do not read the message or its 
attachments, and that you delete them without copying or sending them to anyone else.