use List::MoreUtils qw/first_index last_index/; use 5.010; use strict; use warnings; my @a = qw; my $from = last_index { /DBIC/ } @a; my $to = first_index { /Dancer/ } @a; say for @a[$from + 1..$to - 1];