#original seq
accgttac
#required output
acc #first substring
ccg
cgt
tta
tac #fifth substring
####
#!/usr/local/bin/perl
use strict;
use warnings;
for(){
print substr ($_,0,3),"\n" ;
}
__DATA__
accgttac
##
##
use warnings;
use strict;
my $aoh = [
{
first => 1,
second => ['foo', 'bar', 'baz',],
},
{
first => 2,
second => ['foz', 'barz',],
},
{
first => 2,
second => ['frip', 'barn', 'bazurt',],
},
{
first => 1,
second => ['foo',],
},
];
# use a subroutine to pass a custom
# sort code block
@$aoh = sort by_custom @$aoh;
######## subs ########
sub by_custom{
return ( # sort on first key - numeric ascending
( $a->{first} <=> $b->{first} )
||
( # then by the size of the second key
scalar@{$b->{second} }
<=>
scalar@{ $a->{second} }
)
);
}