Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use Fcntl ':flock'; my $file = '/export/home/smchugh/lock_file.txt'; print FILE "\nI HAVE LOCKED YOU @ @{[scalar localtime]}\n"; open (FILE, ">>$file") || die "Couldn't open $file.\n"; flock(FILE, LOCK_EX | LOCK_NB) || die "Couldn't lock $file.\n"; seek(FILE,0,2); my $loop_var = 0; while (1) { print "File $file is locked." unless $loop_var; select(undef,undef,undef, 250); print "." if $loop_var; $loop_var = 1; }
Edit Masem 2002-02-19 - Changed title from "losing confidence..."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: losing confidence...
by Zaxo (Archbishop) on Feb 14, 2002 at 06:48 UTC |