> foreach $field (@fld_vals) {
Means, iterate through @fld_vals. For each
cell, make $field be an alias to that cell, then
do the bracketed code that follows.
So, if you assign to $field in the code that
follows, you assign to the cell in the array too.
The code gets done once for each cell.
> while ($field = '') {
The bit in brackets assigns null to $field,
and hence to that cell of the @fld_vals array.
The 'while' would start another loop within the
foreach loop (clearly not what you intended)
only it doesn't do anything because the value
of an assignment:
$foo = 3;
is the value of $foo after the assignment is
done, which is 3 (true) in the above case but
is '' (false) in your case.
hth.