Hello, this is my first post on SoPW and I am a novice PERL user so this may well be an easy fix, but I sure can't seem to figure it out. I appreciate any help.

My issue is this, I am writing a program that will read excel spreadsheet files and take specific cells in those spreadsheets and put them in a separate spreadsheet that I am writing in the program. I am using CPAN modules Spreadsheet::Read and Spreadsheet::WriteExcel. However when I run this program I get to the part where I am actually writing the excel output file and I run into this error:

"Can't call method 'write' on an undefined value at bluehillcomp.plx line 94, <STDIN> line 6."

and heres the code at that part:
<# Write 00 temperature data into file:
$read = 4+(($day-1)*58);
$temp = $xls->1{("B", $read)};
$row = $day + 1;
my $worksheet->write($row,$col,$temp); # Line 94 !
$day = $day + 1; >

So I thought this was an issue with me not declaring the variable "$worksheet", but looking at earlier code I think I did declare it:
< my $workbook = ();
my $worksheet = ();
# Create output file with user filename:
if ($outfile ne "d") {
my $workbook = Spreadsheet::WriteExcel->new($outfile);
my $worksheet = $workbook->add_worksheet();
print "What should we label the column containing the data?\n";
my $colname = <STDIN>;
chomp($colname);
$worksheet->write(0,"A",$colname);
} >

Any ideas?


In reply to Issue with Spreadsheet::WriteExcel by mprogan365

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.