Monastery: I am trying to create an excel worksheet using CPAN's writeexcel module. The script works as long as I dont use threads. The moment I try the function through a thread the following happens. 1)script would seem to work if the workbook object were passed to the thread , but the saved excel file would not have data on it. 2)If I try to pass in the worksheet object to the thread the excel file becomes corrupt. Tried all techniques using shared Workbook and Worksheet objects , but had no luck. I had also been through lot of examples and documentation on the Web related to ithreads , thread models and so on , but did not come across anything close to this issue. Would like to know of any feedback the monastery has had with similar attempts made earlier. Here is the script stripped down to the barebone. The original Thought was to gain time at creating a multi tabbed excel file , in which a each tab would be handled by a single thread using an explicit csv file.

#!perl use strict; use warnings; use threads; use threads::shared; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new('test.xls'); my $worksheet = $workbook->add_worksheet('sample'); #---this works processfile($worksheet); #--this will corrupt excel file , irrespective of worksheet being shar +ed or private. #threads->new(\&processfile,$worksheet)->join(); $workbook->close(); sub processfile { my($wrksheet)=@_; $wrksheet->write(0, 0, "Hi Excel!" +); return ; }

In reply to Excel Worksheets and Perl iThread by KarlCiaran

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.