Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    File::Transaction 1.00

    Download button

    No screenshots available
    Downloads: 246  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Nick Cleaton | More programs
    Perl Artistic License / FREE
    September 8th, 2009, 23:25 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    File::Transaction description

    Transactional change to a set of files

    The File::Transaction object encapsulates a change to a set of files, performed by writing out a new version of each file first and then swapping all of the new versions in. The set of files can only end up in an inconsistent state if a rename system call fails or if the Perl process is interrupted during the commit().

    Files will be committed in the order in which they are added to the transaction. This order should be chosen with care to limit the damage to your data if the commit() fails part way through. If there is no order that renders a partial commit acceptable then consider using File::Transaction::Atomic instead.

    SYNOPSIS

     #
     # In this example, we wish to replace the word 'foo' with the
     # word 'bar' in several files, and we wish to minimize the risk
     # of ending up with the replacement done in some files but not
     # in others.
     #

     use File::Transaction;

     my $ft = File::Transaction->new;

     eval {
     foreach my $file (@list_of_file_names) {
     $ft->linewise_rewrite($file, sub {
     s#foo#bar#g;
     });
     }
     };

     if ($@) {
     $ft->revert;
     die "update aborted: $@";
     }
     else {
     $ft->commit;
     }



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    transactional change | file transaction | Perl module | Perl | transaction | change

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM