http://www.perlmonks.org?node_id=1227304


in reply to Grep Pattern

Another one, with rotating:
#!/usr/bin/perl # https://perlmonks.org/?node_id=1227147 use warnings; use strict; my $short_pattern = 'FTTF'; my @result = grep { $short_pattern = ( chop $short_pattern ) . $short_patt +ern; $short_pattern ge 'T' } 0 .. 12; print "@result\n";
P.S. note a wrong rotation direction. So, the pattern should be reversed before, if it's not a palindrome.