open(LOG, "file.ext") or die "$! oops"); my $data = ; close(LOG) open(LOG, ">/path/to/new/file.ext") or die ("$! oops"); print LOG $data; close(LOG);