0

I have an array of arrays

push @fail_codes,[$r->[5],$row->[1]];

that looks like that

STRING_1, VALUE_1

STRING_1, VALUE_1

STRING_1, VALUE_2

STRING_1, VALUE_3

STRING_2, VALUE_1

STRING_2, VALUE_1

STRING_2, VALUE_2

I don't know in advance the FC strings neither the values.

What I would like to do is to count the items in the way that I get

STRING_1 was found n times with values VALUE_1

STRING_1 was found n times with values VALUE_2

STRING_2 was found n times with values VALUE_3 etc

1 Answer 1

2
my %seen;
$seen{"$_->[0] was found %d times with value $_->[1]"}++ for @fail_codes;

printf("$_\n", $seen{$_}) for sort keys %seen;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.