CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
date stamps on files



Jun 19, 2005, 2:13 PM

Post #1 of 1 (843 views)
date stamps on files Can't Post


I am just having problems here with my little code down below..what iam trying is do is create a new file for logs to be stored at when the date changes and that should be done daily hence i will have a file date stamp on each seperate file..i tried the below code but it just doesnt creates a new file for each date jst keeps writing to the same file with the old date stamp..

any ideas?

my @t = localtime(time);

my $fileTimeStamp = ($t[5]+1900) . "-" . ($t[4]+1) . "-" . $t[3];

open(OUTPUT_FILE, ">>/data2/logs/t5/$hostname\_$port\_$fileTimeStamp.$type");

select OUTPUT_FILE; $| = 1;

my $line;

while (<SOCKET>)
my @ct = localtime(time()); # current localtime

my $currentTimeStamp = ($t[5]+1900) . "-" . ($t[4]+1) . "-" . $t[3];

if($fileTimeStamp ne $currentTimeStamp)

$fileTimeStamp = $currentTimeStamp; # set file stamp to current for use in open and later checks
close OUTPUT_FILE || warn($!);
open(OUTPUT_FILE,">>/data2/logs/t5/$hostname\_$port\_$fileTimeStamp.$type") || die($!);


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives