Hi Shlomi, All Thanks for your remarks. As for them:
cunk_size -- oops misspelled, since i wrote the example first hand on this email. no need for \G or \g since the text is single line only (it's a join of array values, seperated with , characters). my question, is based on performance only, where using index on arrays vs. using regular expression for finding the chuck size (X number of elements). I was told, that regarding system resource, when applaying a buffer size (for the array string), will cost the system it's memory. while using index based on an array it's less memory "expencive" what you think ? thanks Chanan On Wed, Nov 24, 2010 at 8:36 PM, Shlomi Fish <[email protected]> wrote: > Hi Chanan, > > a few comments on your code. > > On Wednesday 24 November 2010 13:46:43 Chanan Berler wrote: >> Hello All, >> >> I wonder what you all think is best performace (yes, i could do >> benchmark, but thought of asking). >> thanks >> Chanan >> >> Part1: >> ====== >> >> my @array = (1..200); >> my $step_size = 7; >> >> while (@array) >> { >> my $array_size = scalar(@array); >> my $step = ($array_size > ($step_size - 1) )? >> ($step_size - 1): $array_size; >> my $chunk = join( ',', splice(@array, 0, $step) ); > > No need for the $step calculation here, as splice will extract at most $step > elements - not more. > >> print $chunk, "\n"; >> } >> >> >> Part 2: >> ======= >> my @all_bets = (1..200); >> my $cunk_size = 7; > > You've misspelt "chunk" here. > >> my $bet_txt = join ",", @all_bets; >> $bet_txt .= ","; > >> >> my $cnt = 0; >> my $group; >> while (($group) = $bet_txt =~ /((\d+,){1,$cunk_size})/o) > > The second capturing should be a clustering (?:...) that will make it faster. > Furthermore, don't you want \G and /g here? >> { >> print $group . "\n"; >> $bet_txt = $';#' > > Hmmm.... I see your editor is giving you problems with << $' >>. > >> exit if ($cnt++ == 10); > > What is the purpose of $cnt here? It does not exist in the above code. > > Regards, > > Shlomi Fish > > -- > ----------------------------------------------------------------- > Shlomi Fish http://www.shlomifish.org/ > My Favourite FOSS - http://www.shlomifish.org/open-source/favourite/ > > <rindolf> She's a hot chick. But she smokes. > <go|dfish> She can smoke as long as she's smokin'. > > Please reply to list if it's a mailing list post - http://shlom.in/reply . > -- =================== ---- Chanan Berler ---- =================== _______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
