The regular expression:
(?-imsx:.(?=(R.L)))
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
. any character except \n
----------------------------------------------------------------------
(?= look ahead to see if there is:
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
R 'R'
----------------------------------------------------------------------
. any character except \n
----------------------------------------------------------------------
L 'L'
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
) end of look-ahead
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
####
http://search.cpan.org/perldoc?Acme::Tools
##
##
use strict;
use warnings;
my @array = qw( 1 2 3 4 );
for (my $index = $#array; $index >= 0; --$index){
splice (@array, $index, 1) if $array[$index] =~ /1|3/;
}