Hi,
I am writing a perl script which creates a file (on Linux/UNIX) using
system's date.
e.g. log_2009-07-07.gz

Here is the code I wrote.

#!/usr/bin/perl -w
# Prog for demostrating file name concatenations.
$prefix="log";
$suffix=".gz";

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
# Time
$middle=sprintf "%4d-%02d-%02d \n",$year+1900,$mon+1,$mday;
print "My Date : $middle \n";
$file_name=join("_",$prefix.$middle.$suffix);
print "New File name : $file_name \n";

I am getting value of $file_name as

New File name : 1250_RDE_2009-07-07
.gz

I have even tried to grab date using Linux date command
( i.e. by evaluating $middle=`date +%F`)
But got the same issue

Anyone has any ideas or suggesting regarding this
Thanks in advance.

- - x - X - X - x - -
Thanks & Regards,
Meghanand N. Acharekar
" A  Proud Linux User "
Reg Linux User  #397975
------------------------------------------
I was born free! No Gates and Windows can restrict my Freedom !!!

Reply via email to