Magnetohydrodynamic flow in a rectangular duct with perfectly conducting electrodes