for / foreach syntax issues (in bash or tcsh)

So I am new to unix, and actually anything outside drag and drop with the mouse (been learning for about a week so far) . I have been using the foreach command in tcsh because I am working on a group of files. Basically what I need is to insert part of the filename as the first line in the file. Here is what I have:

% foreach i (first)
foreach? set ${i}
foreach? perl -pi -le' print($ENV{$i}) if $. == 1' "${i}merge_1.txt"
foreach? end

I also tried with double quotes - print($ENV{"i"}), but both only insert a blank space in the beginning of the file.

I tried in bash as well:

for i in first; do
  export "${i}";
  perl -pi -le' print($ENV{"VAR"}) if $. == 1' "${i}merge_1.txt";
done

Again, only a blank space at the beginning of the file...
I have read some things about how it is difficult to export variables between languages (e.g. into perl), but I found one reference using $ENV with a variable from bash into perl. Is it possible to export the foreach or for variable into perl as in the command above?

Your forum has been mighty helpful over the past 3 days (I have learned tons because of it) so a big thank you to everyone that posts here!

Cheers

---------- Post updated 02-08-10 at 01:28 AM ---------- Previous update was 02-07-10 at 07:49 PM ----------

Figured it out...

$for i in OC_Wv_merge_1.txt; 
do export i=${i}; 
perl -pi -le' print $ENV{"i"} if $. == 1' $i; 
done

And I learned about environment variables in the process...