map acts like a foreach loop, walking through an array (or list) and aliasing $_ to each element in turn. In addition to walking the list, though, map also constructs an array. The upshot is that you can transform an array with it.
But explaining that just made me realize that you can get the same result with a foreach loop in this case:
foreach (@values) {
$_ = '' unless defined;
}
That should be more clear. It updates each undefined element of @values to be the empty string.
Caution: Contents may have been coded under pressure.
|