in reply to flexible string value matching in lists

Just wondering if there is a preferred logical approach to matching 'lists' to other 'lists'?

Yes. Put one of the lists in a hash.

In your case, if you make a hash of your fixed strings:

my %lookup = ( string1=>34, string2=>10, string3=>52, string4=>104, st +ring5=>7 );

Then your code becomes a simple process of splitting your complex strings and doing lookups:

my @bits = split ':', 'string2:string4:totalName'; my $name = pop @bits; my $total = 0; for my $bit ( @bits ) { $total += $lookup{ $bit }; } print OUTFILE "$name,$total";

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: flexible string value matching in lists
by archeman2 (Novice) on Feb 16, 2017 at 17:44 UTC
    I agree with your core suggestion that moving the file data to a hash instead of an array allows me to perform un-ordered/non-sequential matches which is the main problem with my previous approach. Thank you for that !