#!/usr/bin/perl use Data::Dumper ; use Storable qw{ lock_retrieve lock_store } ; $r = {} ; if ( -e $ARGV[0] ) { $r = lock_retrieve( $ARGV[0] ) ; } $Data::Dumper::Varname = 'data' ; $Data::Dumper::Indent = 1 ; $Data::Dumper::Quotekeys = 0 ; $dump = Dumper( $r ) ; $dump =~ s/^(\s+)/' ' x (length($&)*4)/gem ; $tmp_file = "/tmp/$$.tmp" ; open TEMP, "> $tmp_file" ; print TEMP $dump ; close TEMP ; $mtime1 = (stat $tmp_file)[9] ; system "vi $tmp_file" ; $mtime2 = (stat $tmp_file)[9] ; if ( $mtime1 != $mtime2 ) { my $buff ; open TEMP, "< $tmp_file" ; while ( ) { $buff .= $_ ; } close TEMP ; my $data1 ; eval $buff ; lock_store $data1, $ARGV[0] ; print "updated\n" ; } else { print "not modified\n" ; } unlink $tmp_file ;