# Get everything between B and D: perl -lwe 'print join " ", grep scalar(/B/../D/), qw(A B C D E F)' # prints: # B C D