in reply to output from cgi

Or if you just want to append the data to an existing file use >>
open (DAT, ">>yourData"); # note the >> print DAT $foo; close DAT;

Update: Chris function not no caffeine well.. (ie remember to check the open call as mrbbking said)

Also take a look at This