3. Open and re-write one FASTA file containing one protein sequence of TERT MJ

From Biolecture.org

Idea

Using '> (writing mode)', contents of original file rewrite into newfile.
Additionally, I use '-e' to check that file or directory name exists.

Code

#!/usr/bin/perl
use strict;
use warnings;

open(FILE, "TERT.txt");
open(NEWFILE, ">Renamed_TERT.txt");
my@file = <FILE>;
print NEWFILE "@file";
close(FILE);
close(NEWFILE);

if (-e "Renamed_TERT.txt") {
    print "SUCCESS! :)\n";
    }
else {
    print "FAIL:(\n";
}

exit;

Result

-> 'Renamed_TERT' containing same TERT seqences is generated.

[[1]]