in reply to Re: Can't use string ("1") as a SCALAR ref while "strict refs" in use
in thread Can't use string ("1") as a SCALAR ref while "strict refs" in use

Why not split?
my($foo, $bar, $baz, $quux) = split /\s+/, $str;
Plus it is easy to change that one line if your input format changes. Better yet:
# 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 }
You could also capture the entries into a hash once the split is done:
... my %template_value_for; my @fields = qw(foo bar baz quux); @template_value_for{@fields} = @entries;
And now $template_value_for{foo} has field 1, and so on.