Unix and Linux Discussions Tagged with bar |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
5 |
5,510 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,377 |
Shell Programming and Scripting |
|
|
|
1 |
1,789 |
What is on Your Mind? |
|
|
|
3 |
5,791 |
Shell Programming and Scripting |
|
|
|
0 |
5,330 |
Programming |
|
|
|
0 |
4,266 |
Windows & DOS: Issues & Discussions |
|
|
|
2 |
7,777 |
Shell Programming and Scripting |
|
|
|
0 |
1,278 |
UNIX and Linux RSS News |
|
|
|
0 |
2,236 |
OS X Support RSS |
|
|
|
0 |
951 |
Software Releases - RSS News |
|
|
|
0 |
864 |
Software Releases - RSS News |
|
|
|
0 |
1,484 |
UNIX and Linux RSS News |
|
|
|
1 |
4,924 |
Shell Programming and Scripting |
|
|
|
0 |
1,256 |
Software Releases - RSS News |
|
|
|
0 |
1,433 |
UNIX and Linux RSS News |
|
|
|
1 |
16,051 |
UNIX for Advanced & Expert Users |
|
|
|
0 |
982 |
UNIX and Linux RSS News |
|
|
|
0 |
788 |
Software Releases - RSS News |
|
|
|
0 |
2,061 |
UNIX and Linux RSS News |
|
|
|
1 |
4,515 |
Linux |
|
|
|
0 |
997 |
Software Releases - RSS News |
|
|
|
3 |
5,980 |
Shell Programming and Scripting |
|
|
|
5 |
3,383 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
3,721 |
UNIX for Advanced & Expert Users |
|
|
|
5 |
3,559 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
4,613 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
15,748 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
6,953 |
UNIX for Dummies Questions & Answers |
Alzabo::ChangeTracker(3pm) User Contributed Perl Documentation Alzabo::ChangeTracker(3pm)
NAME
Alzabo::ChangeTracker - Saves a set of changes as callbacks that can be backed out if needed
SYNOPSIS
use Alzabo::ChangeTracker;
my $x = 0;
my $y = 1;
sub foo
{
my $tracker = Alzabo::ChangeTracker->new;
$tracker->add( sub { $x = 0; } );
$x = 1;
bar();
eval { something; };
$tracker->backout if $@;
}
sub bar
{
my $tracker = Alzabo::ChangeTracker->new;
$tracker->add( sub { $y = 1; } );
$y = 2;
}
DESCRIPTION
The trick ...
We only want to have one object of this type at any one time. In addition, only the stack frame that created it should be able to clear it
(except through a backout). Why? Here's an example in pseudo-code to help explain it:
sub foo
{
create a tracker;
store some change info in the tracker;
call sub bar;
store some change info in the tracker;
# point Y
clear changes in tracker;
}
sub bar
{
create a tracker; # internally, we really just increment our stack count
store some change info in the tracker;
clear changes in tracker; # point X
}
If at point X we were to really clear out the changes, even the changes just from sub bar, we'd have a problem. Because if at point Y,
things go to hell and we want to back out the changes, we want to back out the changes from sub foo _AND_ sub bar. However, if bar is also
an entry point we want to be able to track changes in bar and clear them from bar.
AUTHOR
Dave Rolsky, <autarch@urth.org>
perl v5.8.8 2007-12-23 Alzabo::ChangeTracker(3pm)