in reply to Re: the variable is not getting assigned
in thread the variable is not getting assigned

I often like using sprintf for it instead of variable concatentation .. note also using single quotes for the string literals means you don't have to have the escaping backslashes...
my $message = sprintf '<event_id="ALTER_%d_%d" source="APP">', $tier, +$code1;

Also, to OP: I second blazar's comments, and would also add to them that your assignment of $severity with the two if statements can simply be written as:
$severity = $code1 ? 1 : 5;
Though, what's the point of $severity ? It doesn't seem to be used...