Awk split doesn't work for empty delimiter

Does anyone know how will I make awk's split work with empty or null separator/delimiter?

echo ABCD | awk '{ split($0,arr,""); print arr[1]; }'

I need output like:

A
B
C
D

I am under HP-UX

Hi,

try:

echo ABCD | awk '{ gsub(/./,"&\n",$0); print $0 }'

Output:

A
B
C
D

HTH Chris

Sorry. I forgot to mentioned that I need to put each character in an array or variable, the reason I use the split function of awk.

Code:

echo ABCD | awk '{ split($0,a,""); for (i in a){print a} }' 

Output:

D
A
B
C

To put in an array in awk-

echo ABCD | awk ' { for ( i = 1; i <= length($0); i++ ) a[i]=substr($0,i,1) } END { for ( i in a ) print a [i]} '

B
C
D
A

Thanks a bunch! The code from pmm works but the one from Christoph Spohr did not. Im not sure why. Anyways, thanks again!