It's done automatically, just inspect params (I haven't done CGI for several months so I am not sure about the details, you might need to add name to your button or something).
Comment on Re^3: Web form to alter files is writing to file before submit button is pressed.