in reply to Re^5: Return 2 arrays, sort the same, and concatenate them
in thread Return 2 arrays, sort the same, and concatenate them

Ok, I might as well comment on my changes ie your problem

empty return, instead of last, in dependency_checks, made @all_pronoun_matches empty

After that, @all_pronoun_matches wasn't all empty, but still had some empty arrayrefs, which is why I added

and @$matches); and @$pronoun_matches);
This should have been a change in dependency_checks to return undef instead of an empty ref, but, well, oh well :)

Next I took a look at \%counts, \%pronouncounts and noticed %counts also contained \%pronouncounts -- and the same went for \@all_matches, it also contained \@all_pronoun_matches, so I went back and modified sub dependency_checks and added not $foundPronouns

That got the program 98% there, except there was a missing count number, naturally, since counts no longer contained pronouncounts, so I changed $header, and we're 99% there, the only thing misssing is an extra newline before header :)

Hopefully it makes sense :)

Replies are listed 'Best First'.
Re^7: Return 2 arrays, sort the same, and concatenate them
by jonc (Beadle) on Jul 04, 2011 at 14:13 UTC

    WOW! I don't know how to thank you (Let me know if there is a way to repay). This helped me learn so much. Just seeing how you debugged it was educational.

    I found the same problems, but didn't know how to fix them: (1)Never thought of checking the whole array, (2)Never thought of using negated if (or unless) instead I just tried else, and failed, and (3)That do loop is new to me.

    Again, thanks a lot.

      WOW! I don't know how to thank you (Let me know if there is a way to repay).

      Just rewrite that stuff until it reads like English :) and watch String Calculator TDD Kata done in Perl

      Additional comment about my tweaks, I hope you noticed there was no need for $foundPronouns since @pronoun_matches serves the same purpose (an array in scalar context, returns the number of elements in that array -- that is what and @$pronoun_matches) did)

      if ( not @pronoun_matches ) {