#!/usr/bin/perl

#  --------
#  PROGRAM:  1lock.pl  (created by Developer's Daily, http://www.DevDaily.com)
#  --------

$LOCK_EXCLUSIVE = 2;
$UNLOCK         = 8;

# -----------------------
# What's about to happen:
# -----------------------
# open the file, lock the file, sleep, then write, then unlock the
# file, then close the file.

open (FILE, ">> test.dat") || die "problem opening test.dat\n";
flock FILE, $LOCK_EXCLUSIVE;
sleep 10;
print FILE "this line printed by 1lock.pl\n";
flock FILE, $UNLOCK;
close(FILE);

