Tie::Toggle - False and true, alternately, ad infinitum.
use Tie::Toggle; tie my $toggle, 'Tie::Toggle'; foreach my $number ( 0 .. 10 ) { next unless $toggle; print $number, "\n"; }
You use Tie::Toggle to go back and forth between false and true over and over again. You don't have to worry about any of this since the magic of tie does that for you by using Tie::Cycle. Any time you access the value, it flips.
Tie::Toggle
Tie::Cycle
You can also use Tie::FlipFlop by Abigail to do the same thing, but with any two values.
Tie::FlipFlop
This source is part of a SourceForge project which always has the latest sources in CVS, as well as all of the previous releases.
http://sourceforge.net/projects/brian-d-foy/
If, for some reason, I disappear from the world, one of the other members of the project can shepherd this module appropriately.
brian d foy, <bdfoy@cpan.org>.
<bdfoy@cpan.org>
Copyright 2000-2004, brian d foy, All rights reserved
This software is available under the same terms as perl.
To install Tie::Toggle, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Toggle
CPAN shell
perl -MCPAN -e shell install Tie::Toggle
For more information on module installation, please visit the detailed CPAN module installation guide.