Eureka! I have since found the problem is due to the fact
that @hsbcdataread = $sheets[1]->next_row
is returning an array of less than the expected size of 6
columns. For some reason, sometimes it returns six columns
where one is empty, and other times it just returns 5 columns
instead, meaning that the foreach loop is not always entered
into for the sixth column in my Excel spreadsheet. A quick and
messy if statement has solved this problem. As is often the
case, the problem was not what it initially appeared to be.
Many thanks to those who contributed.
New Code:
while ($sheets[1]->has_data)
{
@hsbcdata = ();
@hsbcdataread = $sheets[1]->next_row;
$size = @hsbcdataread;
if ($size < 6)
{
$hsbcdataread[5] = "X";
}
foreach $_ (@hsbcdataread)
{
s/^\s*//;
s/\s*\r*$//;
chomp ($_);
if (/\S+/)
{
push (@hsbcdata, $_);
}
else
{
push (@hsbcdata, "X");
}
}
.
.
}
| [reply] [d/l] [select] |