Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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=="'

Replies are listed 'Best First'.
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?
[Corion]: Meh. I get the feeling I should post a call-to-action for people to test their modules with the upcoming 5.26 (or 5.25.latest), as it seems that the smoke testers don't really weed out modules that fail without . in @INC
[Corion]: But without instructions on how to easily test things yourself, I don't think such a call to arms is helpful
[Corion]: (this post on nntp.perl.org / p5p makes it seem to me that smoke testers seem to have a blind spot there)
[Corion]: Hmmm. Maybe setting $ENV{PERL5LIB}=" some path without dot"; perl Makefile.PL; make test already is enough to locally test your module...
[Corion]: Meh, no, will need a BEGIN hook...
[Corion]: ... and PERL5OPT does not like -e in it :-(
[Corion]: Ah. The magic invocation is set PERL5OPT=-M-lib=. (equivalent of no lib '.';
[Corion]: )

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2017-03-27 08:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (317 votes). Check out past polls.