Hello All,
Morning,
I am facing problem with my code while creating a log with name as current time stamp using perl. Here is the code.
#!/usr/bin/perl
my $time=localtime;
my ($day,$month,$date,$tm,$year)=split(/ /,$time);
my $stamp=$year."_".$month."_".$date;
my $logdir="SAP_IN_".$stamp;
my $LOGFILE = "E:/pearl/$logdir.log" ;
print " Log file name is : $LOGFILE ";
out put:
E:/pearl/SAP_IN_12:09:04_Feb_.log
It should be
E:/pearl/SAP_IN_12:09:04_Feb_3.log.
I think value of localtime gives date in single digit hence split is failing to get value. But this code works if date in 2 digit.
Can some one help me to correct the code?
Thanks
Krsna..