ksh script modification

Hi
I have some list of files in a .dat
i need to read them line by line and assing them to variables.
For ex: list of files are some,some1
i need two variables g1 as some and g2 as some1.
and then need to perform some operations on g1 and g2
for which i can get some o/p, i need to capture the O/p in a file and again assign them to variables like g1_l1,g1_l2..for g1 and g2_l1,g2_l2....
below is the script that generated but it is not functioning correctly. Can you please help me....

 
r=0
while read line
do
r=$((r+1))
export g=`eval echo $(echo $line)`
c="${g}${r}"
cd $AI_MP
cat $g | grep "|XXGfvertex" | grep ".log" > temp.dat
cat temp.dat | cut -f2 -d ':'| cut -f1 -d "" | tr -d '\' | cut -f1 -d '"' > log_list_$c.dat
l=0
while read line
do
a= $((a+1))
export $c_l$a=`eval echo $(echo $line)`
done<log_list_$c.dat
done<graphlist.dat

made few changes not sure whether it will work or not as i am unable to understand that series of cut and tr do..

 
r=0
while read line
do
r=$((r+1))
#export g=`eval echo $(echo $line)`
eval `echo g$r=$line`
#c="${g}${r}"
cd $AI_MP
eval echo '$'g$i | grep "|XXGfvertex" | grep ".log" > temp.dat
cat temp.dat | cut -f2 -d ':'| cut -f1 -d "" | tr -d "\" | cut -f1 -d '"' > log_list_`eval `echo g$r=$line``.dat
l=0
while read line1
do
a=$((a+1))
#export $c_l$a=`eval echo $(echo $line)`
eval `echo g$r_l$a=$line1`
done < log_list_`eval `echo g$r=$line``.dat
done < graphlist.dat

I guess this might give you some idea to correct the script

To be honest i still don't understand your script, but some things can't be right whatever it may do:

r=$((r+1))
a= $((a+1))

This is better written (similar for the second line, which contains a syntax error anyway):

(( r += 1 ))

Notice the blanks surrounding "((" and "))", they are mandatory.

Then this:

export g=`eval echo $(echo $line)`

whatever this may do, there must be an easier way to do it. The backticks should be replaced by "$(...)", which can be nested:

export g=$(eval echo $(echo $line))

but i suppose the whole line is wrong. First, in ksh you should use "print" instead of "echo", as "print" is a built-in, while "echo" is external to ksh. Second, you have "$line" and want to put the content into "$g" somehow. Why is

export g="$line"

not working? It would help to see some sample input to the script so that we get a picture of what "$line" might contain.

I hope this helps.

bakunin