in reply to file locked?
You may find this File Locking tutorial useful. This is a typical basic method. We use a suck it and see approach. If we can't get a lock on the file we die.
open(MYFILE, ">>$myfile") || die "Can't append to $myfile, Perl says $ +!"; flock(MYFILE, 2) || die "Can't lock $myfile, Perl says $!"; print MYFILE "Hello World!\n"; close MYFILE;
Do you realise that you have written an infinite loop? Your outer loop:
for ($i=0; defined($i); $i++){ print "Help! I'm trapped in an infinite loop\n"; }
will never end as the exit condition defined($i) will always be true. If you really want an infinite loop you could just write:
while (1) { print "foo"; } # or you can write for (;;) { print "foo" }
In either case you will need break out of the loop using a last, unless you are in one of those moods and want to hang the system :-)
Cheers
tachyon
|
|---|