##
# Change this line if the number of entries changes.
use constant ENTRIES_PER_LINE => 4;
...
my @entries = split /\s+/, $str;
if (@entries != ENTRIES_PER_LINE) {
warn "Wrong number of entries: '$str' at line $.\n";
}
else {
# And update this one as well.
my($foo, $bar, $baz, $quux) = @entries;
# continue with your code
}
####
...
my %template_value_for;
my @fields = qw(foo bar baz quux);
@template_value_for{@fields} = @entries;