Hi,

I made the perl script and I print out with Txt file.
For EX :

Open (OUTPUT,">data.txt"));

out put

data.txt

But I hope at the day that I run the script, the day will be labeled with the name file. Like the name below:

20110919data.txt

Could you please show me how to solve this problem.
Thank you very much.

Edited 5 Years Ago by biojet: n/a

use the 'localtime' function and get the date format.

$filename='data.txt';

my ($sec,$min,$hour,$mday,$mon,$year)=localtime();
$year+=1900;
$mon=sprintf("%02d", $mon+1);
$mday=sprintf("%02d", $mday);

my $today_file = "$year$mon$mday"."$filename";

print $today_file;

Read More...

perldoc -f localtime

Edited 5 Years Ago by k_manimuthu: n/a

Thank you very much for your help.
I ask you small question.
how can I have the result 20110919baselist.txt if I use below code

open(BASE,">baselist.txt");

        for (my $i = 0; $i < $num; $i++){
             $base=substr($ref,$posi[$i]-1, 3);	     
              print $base;
              print BASE $base."\n\n";
	}
        close(BASE);

Edited 5 Years Ago by biojet: n/a

This question has already been answered. Start a new discussion instead.