in reply to Re: Perl and Excel
in thread Perl and Excel

Many thanks for your help guys, unfortunately the problem remains. I tried the \w character, and with and without +. Curiouser and curiouser.

Replies are listed 'Best First'.
Re: Re: Re: Perl and Excel
by Anonymous Monk on Jan 14, 2003 at 00:18 UTC
    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"); } } . . }