Return an array of strings from user defined function in awk

Hello Friends,

Is it possible to return an array from a user defined function in awk ?

example:

gawk '
BEGIN{}
{
   catch_line = my_function(i) 
   print catch_line[1]
   print catch_line[2]
   print catch_line[3]
}
function my_function(i)
{
 print "echo"
 line[1]= "awk"
 line[2]= "gawk"
 line[3]= "nawk"

 return line
}
' filename

Actually when I m returning a array from a function it shows me error.. Is it possible to return array ?

Pls help..

Thanks in advance..

Hi,
I am not very sure about your req. But actually there is no need to return. The variable in your user-defined function will be recognized by awk. You can just deal with any variable in function, and out of function in awk other parts you can refer to it.

Just modify your code to follow:

gawk '
BEGIN{}
{
my_function(i)
print line[1]
print line[2]
print line[3]
}
function my_function(i)
{
print "echo"
line[1]= "awk"
line[2]= "gawk"
line[3]= "nawk"
}' filename

Yes Genious .. You are absolutely right...That is my requirment...

Thanks summer_cherry........