Flip-Flop

 view release on metacpan or  search on metacpan

lib/Flip/Flop.pm  view on Meta::CPAN

use v5.8.0;
use warnings FATAL => qw(all);
use strict;
use Carp;
use Data::Table::Text qw(:all);

my @flipflops;                                                                  # Flip::Flops encountered
my $startProcess = $$;                                                          # Starting process

sub AUTOLOAD                                                                    # Any method will do
 {push @flipflops, $Flip::Flop::AUTOLOAD unless @_;                             # No parameters: flop switch, with parameters: flip switch to $[0]
  $_[0]
 }

END
 {if ($startProcess eq $$)                                                      # Reset the flip flops once in the starting process
   {unless($?)                                                                  # Clean run?
     {my $S = my $s = readFile($0);                                             # Read source
      for my $program(@flipflops)                                               # Each flip flop
       {my $f = "$program(0)";                                                  # Regular expression to set the switch to zero
        if ($s !~ m/$f/s)                                                       # Reset the switch if it is not already zero



( run in 0.613 second using v1.01-cache-2.11-cpan-cc502c75498 )