#!/usr/bin/perl my $set = [qw/A000 A123-A456 A999-B000 B789-B888/]; my %elements; for (@$set) { /-/ or $elements{$_} = undef or next; if ( /([[:alpha:]]\d{3})-([[:alpha:]]\d{3})/ ) { my $start = $1; do { $elements{$start} = undef } while $start++ ne $2; } } while () { chomp; print "$_ is ", (exists $elements{$_} ? '' : 'not '), 'in the set.', $/; } __DATA__ A000 A001 A122 A123 A124 A154 A320 A455 A456 A457 A530 A779 A932 A998 A999 B000 B001 B123 B666 B788 B789 B790 B820 B887 B888 B889 B900