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

# initialisation de tableau
my @tab = ("tcgtgccca", "tgtt", "cccga", "ttcatcag", "ggcaag", "ctg",
   "ggtgtaccggtgatcac", "ccaccta", "cctgaattat"
  );

# boucle d'affichage du tableau
foreach my $seq (@tab){
     print $seq, " \n";
}
print " \n";

# declaration de variables
my $seq;
my @small_seq;
my @medium_seq;
my @large_seq;
my $max_seq="";

foreach $seq (@tab){
    if (length($seq)<6){
        push( @small_seq, $seq);
    }
    elsif (length($seq)<10){
        push( @medium_seq, $seq);
    }
    else{
        push( @large_seq, $seq);
    }         
    if( length($seq) > length($max_seq) ){
	$max_seq = $seq;
    }
}

# affichage avec join:
print "séquences courtes:\n" ;
print join(" ",@small_seq), "\n\n";

print "séquences moyennes:\n" ;
print join(" ",@medium_seq), "\n\n"; 

print "séquences longues:\n" ;
print join(" ",@large_seq), "\n\n";  

print "la plus longue: ", $max_seq, "\n";
