Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^2: Anagrams & Letter Banks

by dominick_t (Acolyte)
on Oct 27, 2017 at 19:40 UTC ( #1202188=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1202188]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2022-05-22 19:36 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (81 votes). Check out past polls.