I realize this does not answer your question, but
I would like to suggest an improvement to the way in which you populate the
@toppings array. The following code:
- Eliminates warnings of the type "Scalar value @topping[0] better written as $topping[0]" when you use warnings;
- Eliminates compiler errors of the type "Bareword "Cheese" not allowed while "strict subs" in use" when you use strict;
- Replaces N scalar variables with 1 hash. In your case, N=3; but N would grow as you add onions, mushrooms, etc. $cheese, $pepperoni and $sausage are replaced by %types.
- Reduces the number of lines of code by about 50% as N grows.
my %types;
for (@fields) {
$types{Cheese}++ if /cheese/i;
$types{Pepperoni}++ if /pepperoni/i;
$types{Sausage}++ if /sausage/i;
}
my @toppings = sort keys %types;