in reply to Statistics Data Structure Hash of Arrays, Arrays of Array

Another quick question: What is your purpose for this code:

my @crl = grep { /^$c*/ } @lfq; my @res = grep { !/^$c*/ } @lfq; push @crl, @res;
  1. You carefully filter all the records from @lfq that start with $c into @crl;
  2. Then you equally carefully extract all the records from @lfq that don't start with $c into @res;
  3. Then you put all those carefully selected records back together in the same array.

Effectively the result of those 3 expensive lines is the same as: @crl = @lfq; apart from the side effect of retaining some records in @res that could have been obtains much more efficiently by omitting 2 of the 3 lines!?

It might be better if instead of showing how you are doing things; you told use what you are trying to do in terms of inputs -- files and console -- and expected output.

At the moment it is hard to know where to start to help you as the code you've posted doesn't make a whole lot of sense and there doesn't appear to be a question.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Statistics Data Structure Hash of Arrays, Arrays of Array
by etj (Priest) on May 19, 2022 at 16:16 UTC
    It would reorder @lfq so that all the $c-beginning entries go first. Not at all equivalent to a simple copy.