On Mon, Apr 08, 2002 at 11:05:28PM +0000, Jean-Pierre Vidal wrote:
> >     So, to summarize, there is no dictionary magic, just
> > unwholesome programming dirty tricks. :)
> 
> I don't agree, 

        Well, okay, you're right. Probably that unwholesome's
too feeble a word to describe the brilliant sickness of it all. :)

> foreach $k (%h) {
         ^^^^^^^^^^
>       print "key=$k value=$h{$k}"
> }

There's your mistake. Try

        foreach $k ( keys %h ){ ... }

and you will be seeing a slightly different picture...

> Sure, I cannot explain why, in program 2, "snooped spooned", for instance, 
> acts as a value in a line and as a key in the next. 

        Because your loop iterate through all keys *and* values of your 
hash?

        %hash = ( Yanick => 'moose', Andrew => 'wombat' );
        print "Here is the array'ified version of the hash: ", %hash, "\n";
        print "Here is its keys: ",   keys( %hash ), "\n";
        print "Here is its values: ", values( %hash ), "\n";

> Then, why all anagrams are valid english 
> words? 

        Because the data we are using are valid English words to start with?

> Why I cannot found valids anagrams if I use another langage?

        Okay, okay, I lied. There is a cleverly dictionary
function hidden in all solutions. See the 'map$' at the beginning
of most of them? The 'map' in this case is not an iterative 
function, but a call to the scarcely documented Tourist.pm module.
The '$' is not part of a scalar variable, but define which country
we wish to use the 'map' of. Of course, here '$' is the shortcut 
for 'usa' (nmemotechnic: American capitalism). The Tourist.pm
module has been implemented to help Perl Mongers on missionary missions
in far-away lands and implement nifty features like only printing out
words that can be understood by the natives and converting values
between the metric and imperial system (something no solutions for
this hole took advantage of). 

        :)

Joie,
`/anick

-- 
Because it's fun. Now, that is a perfectly good reason to
do anything.        -- Kosuke Fujishima, 'Oh my Goddess!'

Reply via email to