Please rewrite your code as a SSCCE and tell us what output you get and what output you want.
In your case, such a SSCCE could be:
#!/usr/bin/perl
use strict;
use warnings;
my $localdir = '\\some\\example\\dir\\HD1FA9';
my $tcId;
if (($localdir =~ m/^[\w\W\s\S]+\\((H|HD)[0-9]{1,3}(FA|FC|C|P|CO)[0-9]
+{1,3})/i) or
($localdir =~ m/^[\w\W\s\S]+\\((FC|LM|CO)+[\w\W\s\S]+)/i)) {
$tcId = $1;
} else {
die "TC directory structure is not proper!";
}
print "Have TC id '$tcId'\n";
Note that under Linux, directory names are separated with the forward slash / not the backslash \.