Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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 can change that to print out however many you want. Maurice

Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2019-11-15 19:04 GMT
Find Nodes?
    Voting Booth?
    Strict and warnings: which comes first?

    Results (84 votes). Check out past polls.