in reply to List::MoreUtils before, after and ... between?
If you are sure that both regexes will be found, you can write something like this:
use List::MoreUtils qw/first_index last_index/; use 5.010; use strict; use warnings; my @a = qw<eval DBIC::3 DBIC::2 DBIC::1 MyApp::3 MyApp::2 MyApp::1 Dan +cer::3 Dancer::2 Dancer::1>; my $from = last_index { /DBIC/ } @a; my $to = first_index { /Dancer/ } @a; say for @a[$from + 1..$to - 1];
If one or both regexes might not match, you'd need to special-case undefined $from and $to.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: List::MoreUtils before, after and ... between?
by Boldra (Curate) on Feb 22, 2012 at 09:13 UTC | |
by moritz (Cardinal) on Feb 22, 2012 at 09:45 UTC |