Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

File Locking

by turnstep (Parson)
on Apr 06, 2000 at 22:33 UTC ( [id://7058]=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    open(MYFILE, ">>$myfile") || die;
    flock(MYFILE, 2) || die;
    print MYFILE "Cottleston Pie\n";
    close(MYFILE);
    
  2. or download this
    
    #!/usr/bin/perl
    ...
    print "You are now in my list, $newfriend!\n"
    exit;
    
  3. or download this
      open(MYFILE, ">$myfile") || die;
    
  4. or download this
      flock FILEHANDLE, OPERATION
    
  5. or download this
      sub LOCK_SH { 1 } ## shared lock
      sub LOCK_EX { 2 } ## exclusive lock
      sub LOCK_NB { 4 } ## non-blocking
      sub LOCK_UN { 8 } ## unlock
    
  6. or download this
    
    #!/usr/bin/perl
    ...
    print "You are in my list, $newfriend!\n"
    exit;
    
  7. or download this
      flock(MYFILE, 1);
    
  8. or download this
      flock(MYFILE, 2);
    
  9. or download this
      open(MYFILE, "+< $myfile") || die;
    
  10. or download this
      seek(MYFILE, 0, 0); truncate(MYFILE, 0);
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perltutorial [id://7058]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-03-28 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found