use Modern::Perl; my @string = qw(a a b h a g s j s z u u e); for (1 .. @string) { say join '', @string; shift @string; }