my $readfile= open(READ, "<$file"); my $writefile = open(WRITE, ">test.pl"); rename($writefile, $file);