use strict;
use warnings;
#this script we open a file, do a flow control and conditional test 

#open file
my $file="example.fasta";
open (FILEHANDLE,$file); 
my @array=<FILEHANDLE>;
close FILEHANDLE;


#last time we tried foreach, now we use for
for(my $i=0; $array[$i]; $i+=1)
#for has 3 parts: beginning condition (starting from first element of array, $i=0), ending condition ($array[$i], so when $i is no longer in the array it will give false value and for loop ends); incrementation (each time $i adds 1)
{
chopm  $array[$i]; 
print $array[$i], "\n"; 

#now we try simple test: if the line is short it's sequence id; otherwise it's sequence

if(length($array[$i])<=100)
#do this test and if TRUE, run the following in curly brackets
{
print "this is an sequenc ID, \n";
}
else
#if false than run the following one. you can make this conditional test longer by if/elsif(more times)/else; opposite to if (test for FALSE and do something) there is "unless"; 
{
print "this is an sequence \n";
}
}


#while loop is bit different: it only test the ending condition 
while (@array)
{
my $temp=shift @array;
#the shift keep deleting elements from @array, so if @array is empty, "while" will stop running the code in curly brackets
chomp $temp; 
print $temp, "\n"; 
}
