set variable with another variable? c shell

okay, this shouldn't be difficult but I can't figure it out. How can I set a variable with another variable. I have the following:

foreach pe ($dir $sp)

set tpe = `echo $pe | grep M`
if ($tpe == M) then

set ${$pe} = M <--- This doesn't work

else
endif

end

In this case what I want is to reset the varialbe $dir within the if statement.

Any ideas?

Wrong:

set ${$pe} = M

Good:
set pe = M

Looks like I was just over thinking the issue. Thanks. :wink: