You're replying to a comment by Peteris Krumins.

January 08, 2010, 15:27

q, really easy, the ("a".."z") part creates a list of all letters from a to z. You can think of it as putting all letters in an array:

perl -le '@letters = ("a".."z")'

Next, this array can be indexed to choose individual letters from it. There are 26 letters in the alphabet so $letters[0] is "a" and $letters[1] is "b", ..., $letters[25] is "z".

Now what I do is I use rand function to choose some letter at random:

perl -le '@letters = ("a".."z"); print $letters[rand 26]'

But you can skip the @letters array and just use ("a".."z") in its place:

perl -le 'print (("a".."z")[rand 26])'

And I need to do this several times, so I create a loop that executes 8 times by using map function on a range 1..8,

perl -le 'print map { ("a".."z")[rand 26] } 1..8'

That's it.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "cloud": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.