Perl / File Manipulation / Writing to a File
Snippet details
ID: 95
Viewed: 1524
Added: 2002-03-07
Version:
This little peice of code will write to a file that you tell it.
the contents depend on what you put in the PRINT line. this will also lock the file so nobody can write to it at the same time you are. then it will unlock it and close it.
very good for a flat file database for guestbooks and counters.
the contents depend on what you put in the PRINT line. this will also lock the file so nobody can write to it at the same time you are. then it will unlock it and close it.
very good for a flat file database for guestbooks and counters.
General Details
Snippet uploaded by: snippet
Email : webmaster@snippetlibrary.com
Snippet By: snippet
<!---Head--->
none
<!---Body--->
#!usr/bin/perl
$Datafile = "data.txt";
open(THEFILE,">>$Datafile") || die "Can't open $Datafile: !$n";
flock(THEFILE, 2); #Lock
print THEFILE "whatever you put here will be written to the filen";
flock(THEFILE, 8); #Free
close(THEFILE);
No Reviews to show
