My goal is to remove from the raw stack the records that are not in the good keys list.
How do I achieve this in the most efficient manner? The code I'm currently working on feels dragging. I'm open for suggestions.
Please do note that the values could get ridiculously large.
Here's my data:
# Main data container my %raw_stack = ( 'a1~a2~a3' => 'dat1~dat2', 'b1~b2~b3' => 'dat1~dat2', 'c1~c2~c3' => 'dat1~dat2', 'd1~d2~d3' => 'dat1~dat2', 'e1~e2~e3' => 'dat1~dat2', ); # Container of stack keys only my @stack_keys = ( 'a1~a2~a3', 'b1~b2~b3', 'c1~c2~c3', 'd1~d2~d3', 'e1~e2~e3', ); # Container of valid keys my @good_keys = ( 'a2', 'c2', 'e2', );
Here's the code I'm currently working on:
foreach my $good_key (@good_keys) { foreach my $stack_key (@stack_keys) { my @stack = split(/~/, $stack_key); if ($stack[1] eq $good_key) { } } }
I feel like there's a way to not need the stack keys container. I just don't know how...