Variables in HERE DOCUMENT

Here is my problem: can we set the variables in the HERE DOCUMENT? I have tried but failed. Any one has good comments please let me know.

#!/bin/csh -f

pbrun -u xmgbrk runshell <<!
@ $num1 = `wc -l /home/tpltp/csh/scripts/who.csh`
echo "$num1"
if ( $num1 > 0 ) then
  echo $num1 | tee -a /tmp/file.$$
endif

exit
!
echo "out of csh"
exit(0)

The output will be "@: Variable name must begin with a letter."

PS: I will have no chance to input the password for xmgbrk. this is also a problem.

"HERE" docs and batch runs don't mix. That's because the HERE document is sent to the standard input of "pbrun" which doesn't know what to do with it (it think it's a batch command maybe??)