awk -v -- Why doesn't my example work?

Hi. I've been playing around a bit. This isn't for any practical purpose-- it's really just a theoretical exercise. I wrote this little thing:

foreach num ( 6 5 4 )
awk -v "number=$num" 'BEGIN{for(x=0;x<$number;x++) printf "-"; printf "\n"}'
end

I would expect the following output:

------
-----
----

But I get nothing but blank lines. The awk -v is still a little odd to me-- I can generally use it, but once in a while, its behavior seems anomalous. Anyway, what am I doing wrong?

for num in 6 5 4
do
awk -v number=$num 'BEGIN{for(x=0;x<number;x++) printf "-"; printf "\n"}'
done

The awk command should look like:

awk -v number="$num" 'BEGIN{for(x=0;x<number;x++)  printf "-"; printf "\n"}'

Oh, holy cow... how did I miss that? I guess $ really is the root of all evil. :rolleyes:

Many thanks for the help.