Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Auto flock

by Tommy (Chaplain)
on Nov 19, 2012 at 23:41 UTC ( #1004636=note: print w/ replies, xml ) Need Help??


in reply to Auto flock

Using File::Util will do this for you automatically.

use File::Util; my $ftl = File::Util->new(); # write to a file: (It is automatically locked) $ftl->write_file(file => '/foo/bar/baz.txt', content => 'blah blah bla +h'); # read from a file: (It is automatically locked) my $content = $ftl->load_file("/foo/bar/baz.txt"); # to get an open filehandle that is automatically locked, # see http://search.cpan.org/~tommy/File-Util-3.30_003/Util.pod#open_h +andle
--
Tommy
$ perl -MMIME::Base64 -e 'print decode_base64 "YWNlQHRvbW15YnV0bGVyLm1lCg=="'


Comment on Re: Auto flock
Select or Download Code
Re^2: Auto flock
by space_monk (Chaplain) on Nov 20, 2012 at 02:46 UTC

    I get the impresssion that the OP is aware of the various methods of locking, but wants a way of making the code lock files without making any changes to the (already existing) main body of code.

    I couldn't quite get that far in my earlier suggestion, but thought a 1 letter regex was a close as you could get. ;-)

    A Monk aims to give answers to those who have none, and to learn from those who know more.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2015-07-04 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls