use strict;
use warnings;
#this script we try the I/O for files--it's done by FILEHANDLE--it's also special variable in perl and should be always capital letters


my $file="example.fasta";

open (FILEHANDLE,$file); 
#all contents from example.fasta goes to FILEHANDLE
my @array=<FILEHANDLE>;
#take them to @array--it's usually an array
close FILEHANDLE;
#close FILEHANDLE--save memeory and avoid damaging the file

#have a look at the content
print @array; 


foreach my $temp (@array)
{
print $temp, "\n"; 
#see what is bit wrong? remember the end-of-line thing??? it's actually quite a problem as it always has a "\n" at end--so we need to chomp the last symbol out
chomp $temp; 
#now see it again
print $temp; 

}


#we now transfer all contents to new file--still open a new file by FILEHANDLE but in order to create new file we need to use ">" before. other options include "<" read (but it's usually not used as read is default), ">>" add and "+>" and so on...
open (FILEHANDLE1,">new_file");
#give the value of @array to FILEHANDLE1 by print 
print FILEHANDLE1 @array;
#close FILEHANDLE1 will save the file
close FILEHANDLE1; 
