Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

RE: Random letters

by buzzcutbuddha (Chaplain)
on Apr 12, 2000 at 17:41 UTC ( #7379=note: print w/ replies, xml ) Need Help??


in reply to Random letters

foreach $x ('a' .. 'z') {$alph->{$y} = $x; $y++;} foreach (0 .. 25) {$b = rand 25; $alph->{int $b}, "\n";} This will print out 25 random letters from the hash...you can change that to print out however many you want. Maurice


Comment on RE: Random letters
RE: RE: Random letters
by chromatic (Archbishop) on Apr 12, 2000 at 18:44 UTC
    Hmm, you've just reinvented the array. :)

    Seriously, there's no advantage in using a hash with ascending numeric keys corresponding to the letters of the alphabet (especially as you use zero as a base) over a simple array.

    The array is faster and slightly easier to read, too, not to mention much easier to initialize: my @letters = (a .. z);

      Duh...I should have realized that. It seemed fine when I ran it, but looking at the other versions, I see now my mistake! :) Still not bad for a Perl newbie. I did not partake of one of the three virtues: laziness. doh! thanks for the insight. -Maurice

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-10-01 01:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (386 votes), past polls