March 2002 | Perl Hardware Store | 19 |
Let's write a program that will either update or print out a file's contents:
$FILE = '/data/hitcounter';
print "Content-type: text/html\n\n";
if (something()) { open F, $FILE or die ...; print while <F>; } else { open F, "> $FILE" or die ...; my $data = qx{some command}; print F $data; }
close F;
Oops, it has a race condition
Better slap a little file locking on it
Next | Copyright © 2002 M-J. Dominus |