convert variable content to array

Hi All,

I have a variable in a shell script which holds let say n paarmeteres with space separate them :

$var = par1 par2 par3 par4 parn;
so if I print this variable this is what I'll see:
par1 par2 par3 par4 parn

I need to insert each parameter to an array , so I can go over on each of this parameters with a loop command.
Actually it doesn't have to be in an array , I just need to find away to go over on each parameter in this variable and preform some operation on it.

Any suggestions ?

Thanks

If there are no other special characters in the strings, simply loop over them.

for f in $var; do
  echo I see "$f"
done

A solution without using array :

var='par1 par2 par3 par4'
for param in $var
do
   echo "Param=$param"
done

Output:

Param=par1
Param=par2
Param=par3
Param=par4

Now with an array (under bash) :

var='par1 par2 par3 par4'
declare -a array=( $var )
for (( i=0; i<${#array[*]}; i++ ))
do
   echo "Param=${array}"
done

Jean-Pierre.

use perl

@arr=split(" ",$var);