my $text2 = "$text$text"; my $bwt = join('', map{substr($text2, $_-1, 1)} sort{substr($text2,$a) cmp substr($text2,$b)} 0..length($text)-1 );