I have an array with sequences as shown below in it
my @a = qw(AAAA CGTGATG CGTGATTTGG);
I want to print out the sequence which is longest in the length using perl. So output should be
CGTGATTTGG
#!/usr/bin/perl-w
use strict;
use warnings;
use List::Util qw( min max );
my %hash = ();
my @a = qw(AAAA CGTGATG CGTGATTTGG);
foreach(@a){
print join("\t",$_,length($_)),"\n";
}
Which prints out
AAAA 4
CGTGATG 7
CGTGATTTGG 10
I just want to print the seq with the longest string that is 10
How can I do it
Thanks