#!/usr/bin/perl my $file = '/path/to/some/file'; open FILE, ">$file" or die_nice( "Could not open $file, Reason $!\n" ); print FILE "Woo-hoo!"; close FILE; print header(), "

Wrote $file OK

"; sub die_nice( print header(), shift; exit } sub header { return "Content-type: text/html\n\n" }