The short answer is that you are working with UTF-8 formatted files and the first record in your file contains 3 extra bytes (called the Byte Order Mark or BOM) to mark the file as Unicode. However, you are not telling Perl to treat them as UTF-8 files. You need to either:
- Save your files in ASCII (which will probably break hospitals.csv since one of the hospital names contains a Unicode character).
- Tell Perl to read the files as UTF-8.
To do #2, you just can change the file open lines to:
open (HOSPITALS, '<:utf8', "hospitals.csv") or die $!;
...
open (PATIENTS, '<:utf8', "september.csv") or die $!;
Another option is to use
File::BOM to add BOM detection to your script.
As a positive side-effect to the change suggested above, the 3-argument version of open is safer than the 2-arg version if you ever decide to use a variable name in your filenames (e.g., "$month.csv").
Perl has excellent Unicode support (better than most), but, for whatever reason, it does not have built-in BOM detection for input files. (It does detect BOM for script files it will be executing, just not for regular input files.)
Cheers.