You're viewing a comment by Gaurav and its responses.

Gaurav Permalink
May 14, 2012, 16:52

thnx very much peter ..... can u please explain it at the point "/$a[$1-1]/" ..... and one more thing can we do the same thing by sed ?

Comment Responses

May 16, 2012, 13:40

It's hard to do it in sed.

Here is what $a[$1-1] does. First (\d+) captures the number in the group $1, then $a[$1-1] just accesses the $1-1 element in the @a array.

For example, if the number is 2, then (\d+) captures 2 in $1, and $a[$1-1] is $a[1], which is string "bb", because array @a is ("aa", "bb", "cc", ..., "bx").

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

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

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