in reply to Parsing error
open(FH, "<", "SRC185.xlsx" ) or die; ... while (<FH>){ chomp; ...
An XLSX is a binary file. You cannot just read it line-by-line as if it was newline-separated text and assume you're going to get meaningful data. To read through the rows of SRC185.xlsx, I recommend using the Spreadsheet::Read module -- its documentation shows examples of how to use it to read the various cells of your input spreadsheet. (And even if it were a text-based CSV file instead of XLSX, which is newline-separated text, you would have to somehow split the cells apart to become multiple individual pieces of data; and splitting CSV manually is A Bad Idea, so using Spreadsheet::Read or Text::CSV would have been the better choice for parsing even SRC185.csv.)
Also, the Anonymous Monk had good information in these posts.
addenda: BTW: kudos on use strict and use warnings -- however, since you are opening files, I highly recommend meanful error messages: saying open(...) or die; is not a helpful message; using open(...) or die "SRC185.xlsx: $!" is better; but if you 'use autodie; as well, then you don't even need to manually die with a self-crafted error message, so you can just open(...) and be done with it.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Parsing error
by MoodyDreams999 (Beadle) on Jan 30, 2023 at 21:41 UTC | |
by pryrt (Abbot) on Jan 30, 2023 at 22:00 UTC | |
by MoodyDreams999 (Beadle) on Jan 31, 2023 at 15:34 UTC |