Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^8: Anagrams & Letter Banks

by Cristoforo (Curate)
on Oct 27, 2017 at 22:23 UTC ( #1202210=note: print w/replies, xml ) Need Help??


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

If grep outputs the words themselves, why is the "next unless" part working?
In list context, grep will output the words, but in scalar context, (here forced by 'unless'), grep will return the number (0 1 2 ...) of times the condition it is testing is true.

In this code, if grep tests a word composed of unique letters, the regex test will fail and applying the negation (!), forms a double negative which is equal to true. Here grep returns 1, (or 2 or more depending how many words are made up of unique letters in @list).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2020-09-28 05:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (143 votes). Check out past polls.

    Notices?