Wierdness with code to display file creation date
From: Bob Dubery (megapode_at_hotmail.com)
Date: 10/13/03
- Next message: James Hull: "Help: Install DBI-Oracle on cygwin with Perl 5.8.0"
- Previous message: Mike Jackson: "multiline regex"
- Next in thread: Anno Siegel: "Re: Wierdness with code to display file creation date"
- Reply: Anno Siegel: "Re: Wierdness with code to display file creation date"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 13 Oct 2003 11:09:40 GMT
Hi,
Environment is SuSE, apache 2.0, Perl 5.008
My code looks like this
# get and print date last modified for the required file...
# get date/time modified in epoch seconds...
$lastModified = (stat($fname))[9];
# convert to GMT...
@arr = gmtime($lastModified);
# day of week...
@temp = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
$theday = $temp[$arr[6]];
# date within month...
$thedate = $arr[3];
$lastModified = length($thedate);
if($lastModified eq 1){
$thedate = '0'.$thedate;
}
# month...
@temp =
('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct'
,'Nov','Dec');
$themonth = $temp[$arr[4]];
# year
$theyear = $arr[5] + 1900;
$output = 'Last-Modified: '.$theday.', '.$thedate.',
'.$themonth;
$output = $output.' '.$theyear.' ';
The idea is to get the file creation date and use that to
generate the Last-Modified header.
When I test the script the output is
Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT
Irrespective of the actual date and time of creation.
But if I put print statements in my code to aid debugging...
# get and print date last modified for the required file...
# get date/time modified in epoch seconds...
$lastModified = (stat($fname))[9];
# convert to GMT...
@arr = gmtime($lastModified);
print "\n...@arr...\n";
THEN the lastModified header starts displaying correctly.
What's going on here. Why does displaying that array before
I start processing it's individual elements to build up the
RFC format date actually make a difference to the
calculation of the date?
- Next message: James Hull: "Help: Install DBI-Oracle on cygwin with Perl 5.8.0"
- Previous message: Mike Jackson: "multiline regex"
- Next in thread: Anno Siegel: "Re: Wierdness with code to display file creation date"
- Reply: Anno Siegel: "Re: Wierdness with code to display file creation date"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]