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");
}
}
.
.
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.