Do not use Switch.pm. It is a bad idea that has gone too far. Switch.pm will introduce hard-to-track bugs into your code by its mere presence. Use a simple table lookup or elsif-based dispatch instead. For further reference, see Categorized Damian Modules.
In your case, you have two ways of progress - you need to decide which one suits your programming style or the problem better:
if ($subkey == 1) {
$acc = $messagebin{$file}{$subkey};
if($debug){&writelog(3,"DEBUG: Account=$acc");}
} elsif ($subkey == 11) {
$ordid = $messagebin{$file}{$subkey};
if($debug){&writelog(3,"DEBUG: OrderId=$ordid");
} elsif ($subkey == 14) {
...
} else { # you should _always_ have an else branch
warn "Unhandled subkey value $subkey.";
};
or, if your subkeys are more of a tabular structure:
my $acc;
my %handler = (
1 => sub { $acc = $messagebin{$file}{1}; },
11 => sub { ... },
);
if (my $code = $handler{+$subkey}) {
$code->($subkey);
# I found it convenient to have the dispatch value
# available in the dispatch handler
} else {
warn "Unhandled subkey value $subkey";
};
In your case, you seem to be filling some data structure, so you might need to create the handler hash and the subroutines in a scope which sees the tables. This might or might not
be convenient in your case.