How to use foreach in Splunk to divide two columns

There's no need for foreach. Simple eval commands should do it for a limited number of fields.

| eval C1=A1/B1,C2=A2/B2, C3=A3/B3

For an indefinite number of fields, we can revisit foreach once you explain "does not work". :-)