for(my $iSheet=0; $iSheet < $oBook->{SheetCount}; $iSheet++) { print "$oBook->{SheetCount}"; }
You immediate problem has been identified by liz and other monks. I just have a little comment on the C style for loop you had. I wrote a little benchmark program to test the efficient of a C style for loop and a Perl style for loop with a set. It probably won't matter to your program since your sheetcount is likely to be small, but nevertheless important to know.
use strict; use warnings; use Benchmark qw/ timethese cmpthese /; my $oBook = { SheetCount => 1000 }; cmpthese(timethese(10000, { 'For_C' => '&For_C', 'For_Set' => '&For_Set', })); sub For_C { my $var; for (my $iSheet=0; $iSheet < $oBook->{SheetCount}; $iSheet++) { $var = $iSheet; } } sub For_Set { my $var; for my $iSheet (0..$oBook->{SheetCount}-1) { $var = $iSheet; } }
And the result -
Benchmark: timing 10000 iterations of For_C, For_Set... For_C: 14 wallclock secs (14.33 CPU) @ 697.84/s (n=10000) For_Set: 7 wallclock secs (7.22 CPU) @ 1385.04/s (n=10000) Rate For_C For_Set For_C 698/s -- -50% For_Set 1385/s 98% --
It shows that the Perl style for loop with a set is about twice as fast as the C style loop. This is a significant performance improvement.

There is one more advantage of the Perl loop over the C loop - in the C style for loop, the following is interpreted for every iteration of the loop -
$iSheet < $oBook->{SheetCount} # hash look up and comparison
while in the Perl style for loop the hash look up is evaluated once only, and hence an increase in performance.


In reply to Re: Perl module problem by Roger
in thread Perl module problem by Anonymous Monk

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.