#!/usr/bin/perl # Note: file testfile.txt must be in same directory, or else # must specify an absolute path open(FP, ">testfile.txt"); # open the file for writing # note - not all platforms support flock() flock(FP, 2); # lock the file print FP "Hello!\n"; # write a line flock(FP, 8); # release the file close(FP); # close file again