# file opened, read into $my_data, closed, and $my_data modified appropriately { local *OUTPUT; open(OUTPUT, "> filename_here") || die "Can't open output file: $!"; print OUTPUT $my_data; close(OUTPUT) || die "Can't close my file: $!"; }