Once you have the name, force it to lowercase so that an entry for
"Maryann" will get filed in the
same place as one for "MaryAnn."
This is also handy for naming the files, as the next statement shows.
The next time you have the same name in $name, the
||= operator kicks in. Remember that
$gilligan ||=
$anything is effectively like
$gilligan =
$gilligan ||
$anything. If the variable on the left is a false
value (such as undef), it's
replaced by the value on the right, but if it's true
(such as a filehandle), the value on the right won't
even be evaluated. Thus, since the hash already has a value for that
person's name, the hash's value is
used and assigned directly to $handle without
having to (re-)create the file.
It wasn't necessary to code the
castaways' names into this program, because they
will be read in as data. This is good because any additional castaway
won't require having to rewrite the program. If
someone's name is accidentally misspelled, however,
it puts some of their data into a new file under the wrong name.