Here's the patterns I use to grep out the systems of a subsector from a sector listing.
Code:
my $sector = shift;
my %sectors =
(
'A' => '0[12345678](0[1-9]|10) ',
'B' => '(09|1[0123456])(0[1-9]|10) ',
'C' => '(1[789]|2[01234])(0[1-9]|10) ',
'D' => '(2[5-9]|3\d)(0[1-9]|10) ',
'E' => '0[12345678](1[1-9]|20) ',
'F' => '(09|1[0123456])(1[1-9]|20) ',
'G' => '(1[789]|2[01234])(1[1-9]|20) ',
'H' => '(2[5-9]|3\d)(1[1-9]|20) ',
'I' => '0[12345678](2[1-9]|30) ',
'J' => '(09|1[0123456])(2[1-9]|30) ',
'K' => '(1[789]|2[01234])(2[1-9]|30) ',
'L' => '(2[5-9]|3\d)(2[1-9]|30) ',
'M' => '0[12345678](3[1-9]|40) ',
'N' => '(09|1[0123456])(3[1-9]|40) ',
'O' => '(1[789]|2[01234])(3[1-9]|40) ',
'P' => '(2[5-9]|3\d)(3[1-9]|40) ',
);
my $pattern = $sectors{ $sector };
foreach (<>)
{
print if /$pattern/;
}