Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Re-runnably editing a file in place

by broquaint (Abbot)
on May 22, 2003 at 09:47 UTC ( #260013=note: print w/replies, xml ) Need Help??


in reply to Re-runnably editing a file in place

Sounds like you want transactions for your files, and rather conveniently, this is just what File::Transaction provides e.g
use File::Transaction; my $ft = File::Transaction->new; $ft->linewise_rewrite($fname); ## do stuff if($file_contents_changed) { $ft->commit } else { $ft->revert }
See. the File::Transaction docs for more info.
HTH

_________
broquaint

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://260013]
help
Chatterbox?
Tanktalus has to figure out why his cb talker isn't working :(
[choroba]: https?
[choroba]: That was at least why my cb talker wasn't working.

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2018-07-15 21:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (326 votes). Check out past polls.

    Notices?