in reply to Perl module problem
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.for(my $iSheet=0; $iSheet < $oBook->{SheetCount}; $iSheet++) { print "$oBook->{SheetCount}"; }
And the result -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; } }
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.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% --
while in the Perl style for loop the hash look up is evaluated once only, and hence an increase in performance.$iSheet < $oBook->{SheetCount} # hash look up and comparison
|
|---|