#!/usr/bin/perl use strict; use warnings; 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 ); $_ = join(' ', @data); while ( /(8[[:xdigit:]])\s+\1/g ) { print "Duplicate $1 found at character " . pos() . "\n"; }