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


in reply to match two elements from an array in a row

my @data = qw( 01 b2 01 00 b6 81 81 01 b4 0a 01 01 01 01 00 01 00 00 01 00 c7 82 82 01 b2 01 00 b8 ); for ( 1 .. $#data ) { if ( $data[$_] =~ /(8[12])/ and $data[$_] eq $data[$_-1] ) { print "Match $1 ending at index $_\n"; } }
(update: rearranged my conditions as perl Kanji's premature optimization. :)