http://qs321.pair.com?node_id=1202188


in reply to Re: Anagrams & Letter Banks
in thread Anagrams & Letter Banks

Thank you, Laurent_R. That definitely clears up how the %seen hash is doing its thing. The bit about the %word hash I already understood . . . It was just the use of $_ that threw me for a moment. If you have thoughts on the question asked at the beginning of the (edited) post, I'd appreciate that as well! Thanks very much for you've already written here.

Replies are listed 'Best First'.
Re^3: Anagrams & Letter Banks
by Laurent_R (Canon) on Oct 27, 2017 at 21:43 UTC
    Basically, you have two loops in a row. In the first loop, each record is assigned to $_. When this loop is finished, $_ does not have any useful value. When you start the second loop, again, each value is assigned to $_.

    No problem here, but there are cases, such as nested loops, where is might become slightly dangerous (you might clobber the value of the outer $_ with the value of the inner $_); in the cases of nested loops, while loops and for don't do exactly the same thing, so it is somewhat unreliable and don't do it unless you really know what you're doing. The best, in the event of nested loops, is to use explicit variables rather than the default topical variable $_.

    On the questions related to your other project (not anagrams), you don't give enough details on what you need and how it is supposed to work. Please specify.