The switch value 'Exposure Bias' does not equal the second case's value (both of them being strings, the string equality is used as per the table in the beginning of POD).
Therefore, when the fall-through causes the switch to go to the second case; it simply fails to match. Since there's no more cases, it quits.
To illustrate, this code will print output Second case for bias
if you run it:
use Switch;
use strict; use warnings;
my $field = 'Exposure Bias';
switch($field){
case 'Exposure Bias' {next;}
case 'Exposure Bias Value' {print 'Exp: ' . $field . "\n";}
case /Exposure Bias/ { print "Second case for bias\n";} # RegExp match
}
It starts to work just like your code (first one matches, next
causes fall-through to second one, second one doesn't match) and since there is a third case, and it matches, that one's block gets executed.
I'm not entirely sure how you wanted the second case to match (e.g. under what logic would "Exposure Bias Value" match "Exposure Bias" value) - the only one that comes to mind was that you wanted your "field" to act as a regular expression and each case value to be a string matched against that regular expression. If so, you need to write it as follows, using the fact that a switch value can be a subroutine reference (unfortunately it can't be a regular expression, although the case one can, as you saw above):
use Switch;
use strict; use warnings;
my $field = sub { return $_[0] =~ /Exposure Bias/ };
switch($field){
case 'Exposure Bias' {next;}
case 'Exposure Bias Value' {print "Exp\n";}
}
The latter produces Exp
output.
UPDATE
Based on the updated info in the question, the easiest thing to do is to simply specify both strings in the second case as an arrayref:
use Switch;
use strict; use warnings;
my $field = "Exposure Bias";
switch($field){
case 'Exposure Bias' { print "First match\n"; next;}
case ['Exposure Bias Value', 'Exposure Bias'] {print "Exp: $field\n";}
}
$ perl ~/a.pl
First match
Exp: Exposure Bias
Better to abstract away the value, of course:
use Switch;
use strict; use warnings;
my $field = "Exposure Bias";
my $exp_bias = 'Exposure Bias';
switch($field){
case "$exp_bias" { print "First match\n"; next;}
case ['Exposure Bias Value', "$exp_bias" ] {print "Exp: $field\n";}
}