in reply to Setting Conditional Variable Based on Partial Match

I think the problem has to do with the fact that I am using the $type variable which is declared in the if block, and the $B1 and $B2 variables which were declared outside of the if block.

Half-right. The problem is that $type is declared in the if block, but it's used outside of the block.

my $type; if ($B1=~ /^\*/ || $B2=~ /^\*/) { $type = "S"; } else { $type = "I"; }

or

my $type = $B1 =~ /^\*/ || $B2 =~ /^\*/ ? "S" : "I";

or

my $type = grep(/^\*/, $B1, $B2) ? "S" : "I";

I didn't read any further. Hopefully, that will give you a good start.